feat log add color
Some checks failed
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (push) Successful in 1m8s
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (push) Successful in 1m27s
linux-mips64-gcc / linux-gcc-mips64el (push) Successful in 1m51s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (push) Successful in 1m11s
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (push) Failing after 1h8m15s
linux-hisiv500-gcc / linux-gcc-hisiv500 (push) Failing after 1h8m12s
linux-x64-gcc / linux-gcc (push) Failing after 1h8m10s
Some checks failed
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (push) Successful in 1m8s
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (push) Successful in 1m27s
linux-mips64-gcc / linux-gcc-mips64el (push) Successful in 1m51s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (push) Successful in 1m11s
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (push) Failing after 1h8m15s
linux-hisiv500-gcc / linux-gcc-hisiv500 (push) Failing after 1h8m12s
linux-x64-gcc / linux-gcc (push) Failing after 1h8m10s
This commit is contained in:
parent
9e2f22fcb9
commit
51f923757d
@ -42,6 +42,28 @@ public:
|
|||||||
FATAL = ULOG_LEVEL_FATAL
|
FATAL = ULOG_LEVEL_FATAL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char *GetConsoleColorPrefix(int level)
|
||||||
|
{
|
||||||
|
switch (level) {
|
||||||
|
case kTrace:
|
||||||
|
return "\033[0;37m";
|
||||||
|
case kDebug:
|
||||||
|
return "\033[0;36m";
|
||||||
|
case kInfo:
|
||||||
|
return "\033[0;32m";
|
||||||
|
case kWarn:
|
||||||
|
return "\033[0;33m";
|
||||||
|
case kError:
|
||||||
|
return "\033[0;31m";
|
||||||
|
case kFatal:
|
||||||
|
return "\033[0;31m";
|
||||||
|
default:
|
||||||
|
return "\033[0m";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *GetConsoleColorSuffix(int level) { return "\033[0m"; }
|
||||||
|
|
||||||
static const char *ToShortString(int level)
|
static const char *ToShortString(int level)
|
||||||
{
|
{
|
||||||
switch (level) {
|
switch (level) {
|
||||||
|
@ -62,7 +62,8 @@ Logger::Log(int32_t level,
|
|||||||
/**
|
/**
|
||||||
* @brief time level_name tag file:line@func msg
|
* @brief time level_name tag file:line@func msg
|
||||||
*/
|
*/
|
||||||
std::string pattern = "{} {} {} {}:{}@{}: {}";
|
std::string pattern = std::string() + Level::GetConsoleColorPrefix(level)
|
||||||
|
+ "{} {} {} {}:{}@{}: {}" + Level::GetConsoleColorSuffix(level);
|
||||||
std::string log_time;
|
std::string log_time;
|
||||||
{
|
{
|
||||||
std::time_t now = time(NULL);
|
std::time_t now = time(NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user