diff --git a/desktop_version/src/Vlogging.c b/desktop_version/src/Vlogging.c index c1da95f3..33f37977 100644 --- a/desktop_version/src/Vlogging.c +++ b/desktop_version/src/Vlogging.c @@ -22,9 +22,11 @@ #define Color_BOLD COLOR("\x1b[1m") #define Color_BOLD_YELLOW COLOR("\x1b[1;33m") #define Color_BOLD_RED COLOR("\x1b[1;31m") +#define Color_BOLD_GRAY COLOR("\x1b[1;90m") static int output_enabled = 1; static int color_enabled = 0; +static int debug_enabled = 0; static int info_enabled = 1; static int warn_enabled = 1; static int error_enabled = 1; @@ -61,6 +63,11 @@ void vlog_toggle_color(const int enable_color) color_enabled = enable_color; } +void vlog_toggle_debug(const int enable_debug) +{ + debug_enabled = enable_debug; +} + void vlog_toggle_info(const int enable_info) { info_enabled = enable_info; @@ -76,6 +83,30 @@ void vlog_toggle_error(const int enable_error) error_enabled = enable_error; } +int vlog_debug(const char* text, ...) +{ + va_list list; + int retval; + + if (!output_enabled || !debug_enabled) + { + return 0; + } + + printf(Color_BOLD_GRAY); + printf("[DEBUG]"); + printf(Color_RESET); + printf(" "); + + va_start(list, text); + retval = vprintf(text, list); + va_end(list); + + putchar('\n'); + + return retval; +} + int vlog_info(const char* text, ...) { va_list list; diff --git a/desktop_version/src/Vlogging.h b/desktop_version/src/Vlogging.h index 90ff9089..7d8cbef2 100644 --- a/desktop_version/src/Vlogging.h +++ b/desktop_version/src/Vlogging.h @@ -12,12 +12,16 @@ void vlog_toggle_output(int enable_output); void vlog_toggle_color(int enable_color); +void vlog_toggle_debug(int enable_debug); + void vlog_toggle_info(int enable_info); void vlog_toggle_warn(int enable_warn); void vlog_toggle_error(int enable_error); +int vlog_debug(const char* text, ...); + int vlog_info(const char* text, ...); int vlog_warn(const char* text, ...); diff --git a/desktop_version/src/main.cpp b/desktop_version/src/main.cpp index 2e9ba47d..02146edf 100644 --- a/desktop_version/src/main.cpp +++ b/desktop_version/src/main.cpp @@ -444,6 +444,10 @@ int main(int argc, char *argv[]) { vlog_toggle_color(0); } + else if (ARG("-debug")) + { + vlog_toggle_debug(1); + } else if (ARG("-noinfo")) { vlog_toggle_info(0);