diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2012-12-08 19:13:59 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2012-12-08 19:13:59 +0900 |
| commit | 9a5fff0de095078932e2878338acaa12a5c9daa3 (patch) | |
| tree | 476e5936c3cc26769a12e03609ec642c418b035e /src/Logger.cc | |
| parent | 2364f809c3facae25c430cadf2fc1d9e651ad37b (diff) | |
Logger: Simplified console output and change level format in log
The date and time are now removed from console output. The log level
is now formatted as "[LEVEL]".
Diffstat (limited to 'src/Logger.cc')
| -rw-r--r-- | src/Logger.cc | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/Logger.cc b/src/Logger.cc index 980f7e83..99e6aa3e 100644 --- a/src/Logger.cc +++ b/src/Logger.cc @@ -126,10 +126,16 @@ void writeHeader size_t dateLength = strftime(datestr, sizeof(datestr), "%Y-%m-%d %H:%M:%S", &tm); assert(dateLength <= (size_t)20); - fp.printf("%s.%06ld %s - ", datestr, tv.tv_usec, levelToString(level)); - if(sourceFile) { - fp.printf("[%s:%d]", sourceFile, lineNum); - } + fp.printf("%s.%06ld [%s] [%s:%d] ", datestr, tv.tv_usec, levelToString(level), + sourceFile, lineNum); +} +} // namespace + +namespace { +template<typename Output> +void writeHeaderConsole(Output& fp, Logger::LEVEL level) +{ + fp.printf("[%s] ", levelToString(level)); } } // namespace @@ -158,7 +164,7 @@ void Logger::writeLog } if(toConsole) { global::cout()->printf("\n"); - writeHeader(*global::cout(), level, 0, 0); + writeHeaderConsole(*global::cout(), level); global::cout()->printf("%s\n", msg); writeStackTrace(*global::cout(), trace); global::cout()->flush(); |
