Changeset 874 for cpp/common
- Timestamp:
- 05/05/19 06:21:06 (6 years ago)
- Location:
- cpp/common
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/log.cpp
r841 r874 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-201 5Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2019 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 8 8 #include "Convert.h" 9 9 10 const char* LOG_LEVEL [] = { "[DEBUG] ", "", "[WARN] ", "[ERROR] ", "[CRITICAL] " };10 const char* LOG_LEVEL_ARRAY[] = { "[DEBUG] ", "", "[WARN] ", "[ERROR] ", "[CRITICAL] " }; 11 11 12 12 void logPrintf_va(const char *obj, const char *method, int level, const char *msgf, va_list va) … … 31 31 va_end(argptr); 32 32 } 33 34 const char* logLevelName(int level) 35 { 36 level = min(LOG_CRITICAL, max(LOG_DEBUG, level)); 37 return LOG_LEVEL_ARRAY[level + 1]; 38 } -
cpp/common/log.h
r511 r874 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-201 5Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2019 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 8 8 #include <stdarg.h> 9 9 10 extern const char* LOG_LEVEL [];10 extern const char* LOG_LEVEL_ARRAY[]; 11 11 #define LOG_FORMAT "%s%s.%s: %s" 12 12 #define LOG_MULTILINE_CONTINUATION "..." 13 14 13 15 14 void logPrintf(const char *obj, const char *method, int level, const char *msgf, ...); … … 17 16 void log_printf(const char *msgf, ...); //a shorthand for printf (a different name again to avoid the risk of confusion with the two functions above. This would be unlikely but possible when the argument types would match) 18 17 void logMessage(const char *obj, const char *method, int level, const char *msg); 18 const char* logLevelName(int level); 19 19 20 20 -
cpp/common/loggers/loggers.cpp
r873 r874 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-201 5Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2019 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 148 148 { 149 149 if (msgs.length() > 0) msgs += '\n'; 150 msgs += ssprintf(LOG_FORMAT, LOG_LEVEL[level + 1], obj, method, msg);150 msgs += ssprintf(LOG_FORMAT, logLevelName(level), obj, method, msg); 151 151 } 152 152 } … … 170 170 return string(""); 171 171 } 172 -
cpp/common/loggers/loggertostdout.cpp
r522 r874 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-201 5Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2019 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 15 15 16 16 const char** LoggerToStdout::default_log_level[] = 17 { LOG_LEVEL , default_log_level_ansicolor };17 { LOG_LEVEL_ARRAY, default_log_level_ansicolor }; 18 18 19 19 const char* LoggerToStdout::default_log_format[] = //note trailing %s (so it's easy to append "\n" later) … … 29 29 void LoggerToStdout::handleSingleLine(const char *obj, const char *method, int level, const char *msg) 30 30 { 31 if (level < -1) level = -1; else if (level>3) level = 3;32 31 #ifdef SHP 33 AppLog(LOG_FORMAT "\n", LOG_LEVEL[level+1],obj,method,msg);32 AppLog(LOG_FORMAT "\n", logLevelName(level), obj, method, msg); 34 33 #else 35 34 if (file) 36 file->printf(LOG_FORMAT "\n", LOG_LEVEL[level + 1], obj, method, msg);35 file->printf(LOG_FORMAT "\n", logLevelName(level), obj, method, msg); 37 36 else 37 { 38 if (level < -1) level = -1; else if (level > 3) level = 3; 38 39 printf(log_format, log_level[level + 1], obj, method, msg, "\n"); 40 } 39 41 #endif 40 42 }
Note: See TracChangeset
for help on using the changeset viewer.