diff options
Diffstat (limited to 'core/logging.c')
-rw-r--r-- | core/logging.c | 83 |
1 files changed, 51 insertions, 32 deletions
diff --git a/core/logging.c b/core/logging.c index 3f6404b..b7f77bd 100644 --- a/core/logging.c +++ b/core/logging.c @@ -1,4 +1,26 @@ +/* + * Rune Game Engine + * Copyright 2024 Danny Holman <dholman@gymli.org> + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + */ + #include <rune/core/logging.h> +#include <rune/core/config.h> #include <stdio.h> #include <string.h> #include <stdarg.h> @@ -23,6 +45,9 @@ void log_output(int level, const char *fmt, ...) { char out[4096]; memset(out, 0, sizeof(out)); + debug_enabled = rune_get_log_debug(); + color_enabled = rune_get_log_color(); + va_list arg_ptr; va_start(arg_ptr, fmt); vsnprintf(out, 4096, fmt, arg_ptr); @@ -58,38 +83,32 @@ void log_output(int level, const char *fmt, ...) { break; } - if (color_enabled == 0) + if (color_enabled == 0) { printf("%s %s\n", lvl_str, out); - else - printf("%s%s %s\n%s", color, lvl_str, out, COLOR_DEFAULT); -} - -void enable_log_debug(void) { - debug_enabled = 1; -} - -void disable_log_debug(void) { - debug_enabled = 0; -} - -#ifdef _WIN32 - -#include <windows.h> - -void enable_log_color(void) { - HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); - SetConsoleMode(handle, ENABLE_VIRTUAL_TERMINAL_PROCESSING); - color_enabled = 1; -} - -#else - -void enable_log_color(void) { - color_enabled = 1; + } else { + printf("%s%s %s\n", color, lvl_str, out); + printf(COLOR_DEFAULT); + } } -#endif - -void disable_log_color(void) { - color_enabled = 0; -} +//#ifdef _WIN32 +// +//#include <windows.h> +// +//void enable_log_color(void) { +// HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); +// SetConsoleMode(handle, ENABLE_VIRTUAL_TERMINAL_PROCESSING); +// color_enabled = 1; +//} +// +//#else +// +//void enable_log_color(void) { +// color_enabled = 1; +//} +// +//#endif +// +//void disable_log_color(void) { +// color_enabled = 0; +//} |