feat support log level
This commit is contained in:
parent
f4cd4149a7
commit
f6b9cc5aee
@ -20,6 +20,7 @@ enum class LogLevel {
|
|||||||
kError,
|
kError,
|
||||||
kFatal,
|
kFatal,
|
||||||
};
|
};
|
||||||
|
void SetLogLevel(LogLevel level);
|
||||||
|
|
||||||
void Log(LogLevel level,
|
void Log(LogLevel level,
|
||||||
const char *tag,
|
const char *tag,
|
||||||
|
@ -97,6 +97,14 @@ GetCurrentUTCTime()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LogLevel g_log_level = LogLevel::kTrace;
|
||||||
|
|
||||||
|
void
|
||||||
|
SetLogLevel(LogLevel level)
|
||||||
|
{
|
||||||
|
g_log_level = level;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Log(LogLevel level,
|
Log(LogLevel level,
|
||||||
const char *tag,
|
const char *tag,
|
||||||
@ -106,6 +114,8 @@ Log(LogLevel level,
|
|||||||
const char *func_name,
|
const char *func_name,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
|
if (level < g_log_level) { return; }
|
||||||
|
|
||||||
static std::atomic_bool allow(true);
|
static std::atomic_bool allow(true);
|
||||||
ScopedAtomicWaiter waiter(allow);
|
ScopedAtomicWaiter waiter(allow);
|
||||||
int len = file_name ? strlen(file_name) : 0;
|
int len = file_name ? strlen(file_name) : 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user