mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 17:38:16 +03:00
Allow disabling output/fine-tuning output
-nooutput disables output completely (both STDOUT and STDERR). -noinfo disables INFO lines. -nowarn disables WARN lines. -noerror disables ERROR lines.
This commit is contained in:
@@ -23,7 +23,11 @@
|
||||
#define Color_BOLD_YELLOW COLOR("\x1b[1;33m")
|
||||
#define Color_BOLD_RED COLOR("\x1b[1;31m")
|
||||
|
||||
static int output_enabled = 1;
|
||||
static int color_enabled = 0;
|
||||
static int info_enabled = 1;
|
||||
static int warn_enabled = 1;
|
||||
static int error_enabled = 1;
|
||||
|
||||
void vlog_init(void)
|
||||
{
|
||||
@@ -47,16 +51,41 @@ void vlog_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
void vlog_toggle_output(const int enable_output)
|
||||
{
|
||||
output_enabled = enable_output;
|
||||
}
|
||||
|
||||
void vlog_toggle_color(const int enable_color)
|
||||
{
|
||||
color_enabled = enable_color;
|
||||
}
|
||||
|
||||
void vlog_toggle_info(const int enable_info)
|
||||
{
|
||||
info_enabled = enable_info;
|
||||
}
|
||||
|
||||
void vlog_toggle_warn(const int enable_warn)
|
||||
{
|
||||
warn_enabled = enable_warn;
|
||||
}
|
||||
|
||||
void vlog_toggle_error(const int enable_error)
|
||||
{
|
||||
error_enabled = enable_error;
|
||||
}
|
||||
|
||||
int vlog_info(const char* text, ...)
|
||||
{
|
||||
va_list list;
|
||||
int retval;
|
||||
|
||||
if (!output_enabled || !info_enabled)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf(Color_BOLD);
|
||||
printf("[INFO]");
|
||||
printf(Color_RESET);
|
||||
@@ -76,6 +105,11 @@ int vlog_warn(const char* text, ...)
|
||||
va_list list;
|
||||
int retval;
|
||||
|
||||
if (!output_enabled || !warn_enabled)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
fprintf(stderr, Color_BOLD_YELLOW);
|
||||
fprintf(stderr, "[WARN]");
|
||||
fprintf(stderr, Color_RESET);
|
||||
@@ -95,6 +129,11 @@ int vlog_error(const char* text, ...)
|
||||
va_list list;
|
||||
int retval;
|
||||
|
||||
if (!output_enabled || !error_enabled)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
fprintf(stderr, Color_BOLD_RED);
|
||||
fprintf(stderr, "[ERROR]");
|
||||
fprintf(stderr, Color_RESET);
|
||||
|
||||
Reference in New Issue
Block a user