feat no color for info log
This commit is contained in:
parent
3bcd014992
commit
9b1de49188
@ -16,7 +16,8 @@ GetConsoleColorPrefix(LogLevel level)
|
|||||||
case LogLevel::kDebug:
|
case LogLevel::kDebug:
|
||||||
return "\033[0;36m";
|
return "\033[0;36m";
|
||||||
case LogLevel::kInfo:
|
case LogLevel::kInfo:
|
||||||
return "\033[0;32m";
|
return "\033[0m";
|
||||||
|
// return "\033[0;32m";
|
||||||
case LogLevel::kWarning:
|
case LogLevel::kWarning:
|
||||||
return "\033[0;33m";
|
return "\033[0;33m";
|
||||||
case LogLevel::kError:
|
case LogLevel::kError:
|
||||||
@ -87,10 +88,7 @@ GetCurrentUTCTime()
|
|||||||
std::strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S", &tm);
|
std::strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S", &tm);
|
||||||
std::string result(buf);
|
std::string result(buf);
|
||||||
#if true
|
#if true
|
||||||
return result
|
return result + fmt::format(".{:03d}Z", static_cast<int>(now % kNumNanosecsPerSec) / kNumNanosecsPerMillisec);
|
||||||
+ fmt::format(".{:03d}Z",
|
|
||||||
static_cast<int>(now % kNumNanosecsPerSec)
|
|
||||||
/ kNumNanosecsPerMillisec);
|
|
||||||
#else
|
#else
|
||||||
return result + "Z";
|
return result + "Z";
|
||||||
#endif
|
#endif
|
||||||
@ -106,13 +104,7 @@ SetLogLevel(LogLevel level)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Log(LogLevel level,
|
Log(LogLevel level, const char *tag, const char *fmt, const char *file_name, int line, const char *func_name, ...)
|
||||||
const char *tag,
|
|
||||||
const char *fmt,
|
|
||||||
const char *file_name,
|
|
||||||
int line,
|
|
||||||
const char *func_name,
|
|
||||||
...)
|
|
||||||
{
|
{
|
||||||
if (level < g_log_level) { return; }
|
if (level < g_log_level) { return; }
|
||||||
|
|
||||||
@ -121,11 +113,9 @@ Log(LogLevel level,
|
|||||||
int len = file_name ? strlen(file_name) : 0;
|
int len = file_name ? strlen(file_name) : 0;
|
||||||
while (len > 0 && file_name[len - 1] != '/') { len--; }
|
while (len > 0 && file_name[len - 1] != '/') { len--; }
|
||||||
|
|
||||||
auto msg = fmt::format("{} {} {} {}:{}@{}: {}", GetCurrentUTCTime(),
|
auto msg = fmt::format("{} {} {} {}:{}@{}: {}", GetCurrentUTCTime(), ToShortString(level), tag, file_name + len,
|
||||||
ToShortString(level), tag, file_name + len, line,
|
line, func_name, fmt);
|
||||||
func_name, fmt);
|
std::cout << GetConsoleColorPrefix(level) << msg << GetConsoleColorSuffix() << std::endl;
|
||||||
std::cout << GetConsoleColorPrefix(level) << msg << GetConsoleColorSuffix()
|
|
||||||
<< std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}// namespace sled
|
}// namespace sled
|
||||||
|
Loading…
x
Reference in New Issue
Block a user