From 07032ab0d0887de315c705bd957574cb13e280a6 Mon Sep 17 00:00:00 2001 From: Dennis Felsing Date: Mon, 5 Jun 2023 09:41:41 +0200 Subject: [PATCH] Add logappend setting To append to log file instead of overwriting it. To use you can create a data/autoexec_client.cfg with: logfile "client.log" logappend 1 Enabled by default --- src/engine/client/client.cpp | 3 ++- src/engine/server/main.cpp | 3 ++- src/engine/shared/config_variables.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 470ee3d0a..5b03d3f92 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -4774,9 +4774,10 @@ int main(int argc, const char **argv) } log_set_loglevel((LEVEL)g_Config.m_Loglevel); + const int Mode = g_Config.m_Logappend ? IOFLAG_APPEND : IOFLAG_WRITE; if(g_Config.m_Logfile[0]) { - IOHANDLE Logfile = pStorage->OpenFile(g_Config.m_Logfile, IOFLAG_WRITE, IStorage::TYPE_SAVE_OR_ABSOLUTE); + IOHANDLE Logfile = pStorage->OpenFile(g_Config.m_Logfile, Mode, IStorage::TYPE_SAVE_OR_ABSOLUTE); if(Logfile) { pFutureFileLogger->Set(log_logger_file(Logfile)); diff --git a/src/engine/server/main.cpp b/src/engine/server/main.cpp index 5371b772d..44938ed9c 100644 --- a/src/engine/server/main.cpp +++ b/src/engine/server/main.cpp @@ -170,9 +170,10 @@ int main(int argc, const char **argv) pConsole->Register("sv_rescue", "", CFGFLAG_SERVER, CServer::ConRescue, pConsole, "Allow /rescue command so players can teleport themselves out of freeze (setting only works in initial config)"); log_set_loglevel((LEVEL)g_Config.m_Loglevel); + const int Mode = g_Config.m_Logappend ? IOFLAG_APPEND : IOFLAG_WRITE; if(g_Config.m_Logfile[0]) { - IOHANDLE Logfile = pStorage->OpenFile(g_Config.m_Logfile, IOFLAG_WRITE, IStorage::TYPE_SAVE_OR_ABSOLUTE); + IOHANDLE Logfile = pStorage->OpenFile(g_Config.m_Logfile, Mode, IStorage::TYPE_SAVE_OR_ABSOLUTE); if(Logfile) { pFutureFileLogger->Set(log_logger_file(Logfile)); diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index a37ec38a3..1f210f870 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -12,6 +12,7 @@ MACRO_CONFIG_INT(PlayerCountry, player_country, -1, -1, 1000, CFGFLAG_SAVE | CFG MACRO_CONFIG_STR(Password, password, 32, "", CFGFLAG_CLIENT | CFGFLAG_SERVER | CFGFLAG_NONTEEHISTORIC, "Password to the server") MACRO_CONFIG_STR(Logfile, logfile, 128, "", CFGFLAG_SAVE | CFGFLAG_CLIENT | CFGFLAG_SERVER, "Filename to log all output to") MACRO_CONFIG_INT(Loglevel, loglevel, 2, 0, 4, CFGFLAG_SAVE | CFGFLAG_CLIENT | CFGFLAG_SERVER, "Log level (0 = Error, 1 = Warn, 2 = Info, 3 = Debug, 4 = Trace)") +MACRO_CONFIG_INT(Logappend, logappend, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT | CFGFLAG_SERVER, "Append to logfile instead of overwriting it every time") MACRO_CONFIG_INT(ConsoleOutputLevel, console_output_level, 0, 0, 2, CFGFLAG_SAVE | CFGFLAG_CLIENT | CFGFLAG_SERVER, "Adjusts the amount of information in the console") MACRO_CONFIG_INT(ConsoleEnableColors, console_enable_colors, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT | CFGFLAG_SERVER, "Enable colors in console output") MACRO_CONFIG_INT(Events, events, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT | CFGFLAG_SERVER, "Enable triggering of events, (eye emotes on some holidays in server, christmas skins in client).")