feat use short log level
Some checks are pending
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (push) Waiting to run
linux-mips64-gcc / linux-gcc-mips64el (push) Waiting to run
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (push) Successful in 55s
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (push) Successful in 1m0s
linux-x64-gcc / linux-gcc (push) Successful in 1m43s
linux-hisiv500-gcc / linux-gcc-hisiv500 (push) Successful in 1m19s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (push) Successful in 1m2s

This commit is contained in:
tqcq 2023-12-28 15:51:28 +08:00
parent 83772e6506
commit 9e2f22fcb9
2 changed files with 22 additions and 2 deletions

View File

@ -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) {

View File

@ -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);