diff --git a/src/ctx.h b/src/ctx.h index 27d4fed..2fdf122 100644 --- a/src/ctx.h +++ b/src/ctx.h @@ -27,8 +27,6 @@ struct { int threads; int depth; - int verbose; - int very_verbose; size_t stat_tn_size; size_t stat_index_size; diff --git a/src/log.c b/src/log.c index b0a27d3..87c263a 100644 --- a/src/log.c +++ b/src/log.c @@ -12,7 +12,7 @@ const char *log_levels[] = { "DEBUG", "INFO", "WARNING", "ERROR", "FATAL" }; -void sist_logf(const char *filepath, int level, char *format, ...) { +void vsist_logf(const char *filepath, int level, char *format, va_list ap) { static int is_tty = -1; if (is_tty == -1) { @@ -46,11 +46,8 @@ void sist_logf(const char *filepath, int level, char *format, ...) { ); } - va_list ap; - va_start(ap, format); size_t maxsize = sizeof(log_str) - log_len; log_len += vsnprintf(log_str + log_len, maxsize, format, ap); - va_end(ap); if (is_tty) { log_len += sprintf(log_str + log_len, "\033[0m\n"); @@ -65,6 +62,13 @@ void sist_logf(const char *filepath, int level, char *format, ...) { } } +void sist_logf(const char *filepath, int level, char *format, ...) { + va_list ap; + va_start(ap, format); + vsist_logf(filepath, level, format, ap); + va_end(ap); +} + void sist_log(const char *filepath, int level, char *str) { static int is_tty = -1; diff --git a/src/log.h b/src/log.h index 78e3c69..1336036 100644 --- a/src/log.h +++ b/src/log.h @@ -40,6 +40,7 @@ #include "sist.h" void sist_logf(const char *filepath, int level, char *format, ...); +void vsist_logf(const char *filepath, int level, char *format, va_list ap); void sist_log(const char *filepath, int level, char *str); diff --git a/src/main.c b/src/main.c index 616c345..9734dc1 100644 --- a/src/main.c +++ b/src/main.c @@ -19,7 +19,7 @@ #define EPILOG "Made by simon987 . Released under GPL-3.0" -static const char *const Version = "2.1.1"; +static const char *const Version = "2.1.2"; static const char *const usage[] = { "sist2 scan [OPTION]... PATH", "sist2 index [OPTION]... INDEX", @@ -55,9 +55,9 @@ void _log(const char *filepath, int level, char *str) { exit(-1); } - if (ScanCtx.verbose) { + if (LogCtx.verbose) { if (level == LEVEL_DEBUG) { - if (ScanCtx.very_verbose) { + if (LogCtx.very_verbose) { sist_log(filepath, level, str); } } else { @@ -76,10 +76,10 @@ void _logf(const char *filepath, int level, char *format, ...) { exit(-1); } - if (ScanCtx.verbose) { + if (LogCtx.verbose) { if (level == LEVEL_DEBUG) { - if (ScanCtx.very_verbose) { - sist_logf(filepath, level, format, args); + if (LogCtx.very_verbose) { + vsist_logf(filepath, level, format, args); } } else { sist_logf(filepath, level, format, args); diff --git a/src/static/search.html b/src/static/search.html index 166fd11..4df0767 100644 --- a/src/static/search.html +++ b/src/static/search.html @@ -11,7 +11,7 @@