Selaa lähdekoodia

Force server logs to stdout/stderr

Make server use standard output streams instead of file-based streams.
master
TheoryOfNekomata 1 vuosi sitten
vanhempi
commit
d8ec780689
4 muutettua tiedostoa jossa 16 lisäystä ja 6 poistoa
  1. +1
    -1
      src/packages/game/IZ_app.c
  2. +13
    -3
      src/packages/log/IZ_log.c
  3. +1
    -1
      src/packages/log/IZ_log.h
  4. +1
    -1
      src/packages/server/IZ_app.c

+ 1
- 1
src/packages/game/IZ_app.c Näytä tiedosto

@@ -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);


+ 13
- 3
src/packages/log/IZ_log.c Näytä tiedosto

@@ -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
}



+ 1
- 1
src/packages/log/IZ_log.h Näytä tiedosto

@@ -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*, ...);


+ 1
- 1
src/packages/server/IZ_app.c Näytä tiedosto

@@ -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);


Ladataan…
Peruuta
Tallenna