diff --git a/src/packages/game/IZ_app.c b/src/packages/game/IZ_app.c index 4482671..682cda1 100644 --- a/src/packages/game/IZ_app.c +++ b/src/packages/game/IZ_app.c @@ -26,7 +26,7 @@ typedef enum { } IZ_AppInitializeResult; IZ_AppInitializeResult IZ_AppInitialize(struct IZ_App* app, u8 argc, const char* argv[]) { - IZ_LogInitialize("game"); + IZ_LogInitialize("game", false); IZ_LogInterceptWSMessages(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE); IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "global", "Starting %s...", IZ_APP_NAME); diff --git a/src/packages/log/IZ_log.c b/src/packages/log/IZ_log.c index 049d794..26c1995 100644 --- a/src/packages/log/IZ_log.c +++ b/src/packages/log/IZ_log.c @@ -40,7 +40,13 @@ bool IZ_LogIsSupportedColor(FILE* s) { #endif } -void IZ_LogInitialize(const char* context) { +void IZ_LogInitialize(const char* context, bool force_output) { + if (force_output) { + stdout_dest = stdout; + stderr_dest = stderr; + return; + } + #ifdef IZ_DEBUG stdout_dest = stdout; stderr_dest = stderr; @@ -54,8 +60,8 @@ void IZ_LogInitialize(const char* context) { char* now = IZ_TimerNowPathSafe(); // fixme - sprintf(stdout_filename, "%s/out-%s-%s.log", log_dir, context, now); - sprintf(stderr_filename, "%s/err-%s-%s.log", log_dir, context, now); + sprintf(stdout_filename, "%s/%s-out-%s.log", log_dir, context, now); + sprintf(stderr_filename, "%s/%s-err-%s.log", log_dir, context, now); IZ_fopen(&stdout_dest, stdout_filename, "a"); IZ_fopen(&stderr_dest, stderr_filename, "a"); #endif @@ -63,7 +69,11 @@ void IZ_LogInitialize(const char* context) { void IZ_LogTeardown() { #ifndef IZ_DEBUG + if (IZ_LogIsSupportedColor(stdout_dest)) { + return; + } fclose(stdout_dest); + fclose(stderr_dest); #endif } diff --git a/src/packages/log/IZ_log.h b/src/packages/log/IZ_log.h index c22d2f1..4d998db 100644 --- a/src/packages/log/IZ_log.h +++ b/src/packages/log/IZ_log.h @@ -34,7 +34,7 @@ typedef enum { static FILE* stdout_dest; static FILE* stderr_dest; -void IZ_LogInitialize(const char*); +void IZ_LogInitialize(const char*, bool); void IZ_LogError(const char*, const char*, ...); void IZ_LogInfo(IZ_LogCategory, const char*, const char*, ...); void IZ_LogWarn(bool, const char*, const char*, ...); diff --git a/src/packages/server/IZ_app.c b/src/packages/server/IZ_app.c index ac807c6..991827e 100644 --- a/src/packages/server/IZ_app.c +++ b/src/packages/server/IZ_app.c @@ -12,7 +12,7 @@ IZ_ProcedureResult IZ_AppInitialize(IZ_App *app, u8 argc, const char **argv) { IZ_memset(app, 0, sizeof(IZ_App)); signal(SIGINT, IZ_AppHandleSignal); - IZ_LogInitialize("server"); + IZ_LogInitialize("server", true); // IZ_LogInterceptWSMessages(app->config.log_level); IZ_LogInterceptWSMessages(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE);