Make server use standard output streams instead of file-based streams.master
@@ -26,7 +26,7 @@ typedef enum { | |||||
} IZ_AppInitializeResult; | } IZ_AppInitializeResult; | ||||
IZ_AppInitializeResult IZ_AppInitialize(struct IZ_App* app, u8 argc, const char* argv[]) { | 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_LogInterceptWSMessages(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE); | ||||
IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "global", "Starting %s...", IZ_APP_NAME); | IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "global", "Starting %s...", IZ_APP_NAME); | ||||
@@ -40,7 +40,13 @@ bool IZ_LogIsSupportedColor(FILE* s) { | |||||
#endif | #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 | #ifdef IZ_DEBUG | ||||
stdout_dest = stdout; | stdout_dest = stdout; | ||||
stderr_dest = stderr; | stderr_dest = stderr; | ||||
@@ -54,8 +60,8 @@ void IZ_LogInitialize(const char* context) { | |||||
char* now = IZ_TimerNowPathSafe(); | char* now = IZ_TimerNowPathSafe(); | ||||
// fixme | // 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(&stdout_dest, stdout_filename, "a"); | ||||
IZ_fopen(&stderr_dest, stderr_filename, "a"); | IZ_fopen(&stderr_dest, stderr_filename, "a"); | ||||
#endif | #endif | ||||
@@ -63,7 +69,11 @@ void IZ_LogInitialize(const char* context) { | |||||
void IZ_LogTeardown() { | void IZ_LogTeardown() { | ||||
#ifndef IZ_DEBUG | #ifndef IZ_DEBUG | ||||
if (IZ_LogIsSupportedColor(stdout_dest)) { | |||||
return; | |||||
} | |||||
fclose(stdout_dest); | fclose(stdout_dest); | ||||
fclose(stderr_dest); | |||||
#endif | #endif | ||||
} | } | ||||
@@ -34,7 +34,7 @@ typedef enum { | |||||
static FILE* stdout_dest; | static FILE* stdout_dest; | ||||
static FILE* stderr_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_LogError(const char*, const char*, ...); | ||||
void IZ_LogInfo(IZ_LogCategory, const char*, const char*, ...); | void IZ_LogInfo(IZ_LogCategory, const char*, const char*, ...); | ||||
void IZ_LogWarn(bool, const char*, const char*, ...); | void IZ_LogWarn(bool, const char*, const char*, ...); | ||||
@@ -12,7 +12,7 @@ IZ_ProcedureResult IZ_AppInitialize(IZ_App *app, u8 argc, const char **argv) { | |||||
IZ_memset(app, 0, sizeof(IZ_App)); | IZ_memset(app, 0, sizeof(IZ_App)); | ||||
signal(SIGINT, IZ_AppHandleSignal); | signal(SIGINT, IZ_AppHandleSignal); | ||||
IZ_LogInitialize("server"); | |||||
IZ_LogInitialize("server", true); | |||||
// IZ_LogInterceptWSMessages(app->config.log_level); | // IZ_LogInterceptWSMessages(app->config.log_level); | ||||
IZ_LogInterceptWSMessages(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE); | IZ_LogInterceptWSMessages(LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE); | ||||