diff --git a/src/ulib/log/level.h b/src/ulib/log/level.h index 5c0c355..6c9ae0e 100644 --- a/src/ulib/log/level.h +++ b/src/ulib/log/level.h @@ -42,6 +42,26 @@ public: FATAL = ULOG_LEVEL_FATAL }; + static const char *ToShortString(int level) + { + switch (level) { + case kTrace: + return "T"; + case kDebug: + return "D"; + case kInfo: + return "I"; + case kWarn: + return "W"; + case kError: + return "E"; + case kFatal: + return "F"; + default: + return "UNKNOWN"; + } + } + static const char *ToString(int level) { switch (level) { diff --git a/src/ulib/log/logger.cpp b/src/ulib/log/logger.cpp index a5531f1..d87aa2f 100644 --- a/src/ulib/log/logger.cpp +++ b/src/ulib/log/logger.cpp @@ -53,7 +53,7 @@ Logger::Log(int32_t level, const char *msg) { if (level < level_) { return; } - const char *level_name = Level::ToString(level); + const char *level_name = Level::ToShortString(level); /** * @brief time file:line@func tag level_name msg */ @@ -62,7 +62,7 @@ Logger::Log(int32_t level, /** * @brief time level_name tag file:line@func msg */ - std::string pattern = "{} [{}] {} {}:{}@{}: {}"; + std::string pattern = "{} {} {} {}:{}@{}: {}"; std::string log_time; { std::time_t now = time(NULL);