Changeset 397 for cpp/common
- Timestamp:
- 06/23/15 00:53:10 (10 years ago)
- Location:
- cpp/common/loggers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/loggers/loggertostdout.cpp
r378 r397 4 4 5 5 #include "loggertostdout.h" 6 #include <common/console.h> 6 7 #ifdef SHP 7 8 #include <FBaseSys.h> //AppLog … … 9 10 #include <stdio.h> 10 11 #endif 12 13 static const char* default_log_level_ansicolor[] = 14 { "[\033[2mDEBUG\033[0m] \033[2m", "", "[\033[33mWARN\033[0m] \033[1m", "[\033[1;31mERROR\033[0m] \033[1m", "[\033[1;31mCRITICAL\033[0m] \033[1m" }; 15 16 const char** LoggerToStdout::default_log_level[] = 17 { LOG_LEVEL, default_log_level_ansicolor }; 18 19 const char* LoggerToStdout::default_log_format[]= //note trailing %s (so it's easy to append "\n" later) 20 { LOG_FORMAT "%s", "%s%s.%s: %s\033[0m%s" }; 21 22 LoggerToStdout::LoggerToStdout(int opts, VirtFILE *_file) 23 :LoggerBase(opts), file(_file) 24 { 25 log_format=default_log_format[console_color_mode]; 26 log_level=default_log_level[console_color_mode]; 27 } 11 28 12 29 void LoggerToStdout::handle(const char *obj, const char *method, int level, const char *msg) … … 19 36 file->printf(LOG_FORMAT "\n", LOG_LEVEL[level + 1], obj, method, msg); 20 37 else 21 printf( LOG_FORMAT "\n", LOG_LEVEL[level + 1], obj, method, msg);38 printf(log_format, log_level[level + 1], obj, method, msg, "\n"); 22 39 #endif 23 40 } -
cpp/common/loggers/loggertostdout.h
r382 r397 13 13 VirtFILE *file; 14 14 public: 15 LoggerToStdout(int opts = 0, VirtFILE *_file = NULL) :LoggerBase(opts), file(_file) {}15 LoggerToStdout(int opts = 0, VirtFILE *_file = NULL); 16 16 void handle(const char *obj, const char *method, int level, const char *msg); 17 18 static const char* default_log_format[]; 19 static const char** default_log_level[]; 20 const char** log_level; 21 const char* log_format; 17 22 }; 18 23
Note: See TracChangeset
for help on using the changeset viewer.