1.1 --- a/core/Logger.cpp Tue Apr 03 07:02:27 2007 +0000
1.2 +++ b/core/Logger.cpp Thu Apr 05 03:02:00 2007 +0000
1.3 @@ -25,10 +25,51 @@
1.4 * :TODO: This should be creating the log folder if it doesn't exist
1.5 */
1.6
1.7 +CoreConfigErr Logger::OnSourceModConfigChanged(const char *option, const char *value)
1.8 +{
1.9 + if (strcasecmp(option, "Logging") == 0)
1.10 + {
1.11 + bool state = true;
1.12 +
1.13 + if (strcasecmp(value, "on") == 0)
1.14 + {
1.15 + state = true;
1.16 + } else if (strcasecmp(value, "off") == 0) {
1.17 + state = false;
1.18 + } else {
1.19 + return CoreConfig_InvalidValue;
1.20 + }
1.21 +
1.22 + if (m_FirstPass)
1.23 + {
1.24 + m_InitialState = state;
1.25 + m_FirstPass = false;
1.26 + } else {
1.27 + state ? g_Logger.EnableLogging() : g_Logger.DisableLogging();
1.28 + }
1.29 +
1.30 + return CoreConfig_Okay;
1.31 + } else if (strcasecmp(option, "LogMode") == 0) {
1.32 + if (strcasecmp(value, "daily") == 0)
1.33 + {
1.34 + m_Mode = LoggingMode_Daily;
1.35 + } else if (strcasecmp(value, "map") == 0) {
1.36 + m_Mode = LoggingMode_PerMap;
1.37 + } else if (strcasecmp(value, "game") == 0) {
1.38 + m_Mode = LoggingMode_Game;
1.39 + } else {
1.40 + return CoreConfig_InvalidValue;
1.41 + }
1.42 +
1.43 + return CoreConfig_Okay;
1.44 + }
1.45 +
1.46 + return CoreConfig_InvalidOption;
1.47 +}
1.48 +
1.49 void Logger::OnSourceModStartup(bool late)
1.50 {
1.51 - //:TODO: read these options from a file, dont hardcode them
1.52 - InitLogger(LoggingMode_Daily, true);
1.53 + InitLogger(m_Mode, m_InitialState);
1.54 }
1.55
1.56 void Logger::OnSourceModAllShutdown()
1.57 @@ -42,6 +83,9 @@
1.58 {
1.59 return;
1.60 }
1.61 +
1.62 + /* Append "Log file closed" to previous log file */
1.63 + _CloseFile();
1.64
1.65 char _filename[256];
1.66 int i = 0;
1.67 @@ -113,7 +157,7 @@
1.68
1.69 void Logger::InitLogger(LoggingMode mode, bool startlogging)
1.70 {
1.71 - m_mode = mode;
1.72 + m_Mode = mode;
1.73 m_Active = startlogging;
1.74
1.75 time_t t;
1.76 @@ -125,7 +169,7 @@
1.77 g_SourceMod.BuildPath(Path_SM, _filename, sizeof(_filename), "logs/errors_%02d%02d%02d.log", curtime->tm_mon + 1, curtime->tm_mday, curtime->tm_year - 100);
1.78 m_ErrFileName.assign(_filename);
1.79
1.80 - switch (m_mode)
1.81 + switch (m_Mode)
1.82 {
1.83 case LoggingMode_PerMap:
1.84 {
1.85 @@ -162,11 +206,11 @@
1.86 return;
1.87 }
1.88
1.89 - if (m_mode == LoggingMode_HL2)
1.90 + if (m_Mode == LoggingMode_Game)
1.91 {
1.92 va_list ap;
1.93 va_start(ap, vafmt);
1.94 - _PrintToHL2Log(vafmt, ap);
1.95 + _PrintToGameLog(vafmt, ap);
1.96 va_end(ap);
1.97 return;
1.98 }
1.99 @@ -190,7 +234,7 @@
1.100 strftime(date, sizeof(date), "%m/%d/%Y - %H:%M:%S", curtime);
1.101
1.102 FILE *fp = NULL;
1.103 - if (m_mode == LoggingMode_PerMap)
1.104 + if (m_Mode == LoggingMode_PerMap)
1.105 {
1.106 fp = fopen(m_NrmFileName.c_str(), "a+");
1.107 if (!fp)
1.108 @@ -287,7 +331,7 @@
1.109 {
1.110 m_CurMapName.assign(mapname);
1.111
1.112 - switch (m_mode)
1.113 + switch (m_Mode)
1.114 {
1.115 case LoggingMode_Daily:
1.116 {
1.117 @@ -313,7 +357,7 @@
1.118 m_ErrMapStart = false;
1.119 }
1.120
1.121 -void Logger::_PrintToHL2Log(const char *fmt, va_list ap)
1.122 +void Logger::_PrintToGameLog(const char *fmt, va_list ap)
1.123 {
1.124 char msg[3072];
1.125 size_t len;
1.126 @@ -348,7 +392,7 @@
1.127
1.128 LoggingMode Logger::GetLoggingMode() const
1.129 {
1.130 - return m_mode;
1.131 + return m_Mode;
1.132 }
1.133
1.134 void Logger::EnableLogging()