16 "core",
"platform",
"gpu",
"workgraph",
"sim",
"reaction",
"physics",
"render",
"audio",
"tool",
20 "trace",
"debug",
"info",
"warning",
"error",
"fatal",
36 const auto index =
static_cast<size_t>(channel);
37 if (index >= CHANNEL_NAMES.size())
40 return CHANNEL_NAMES[index];
44 const auto index =
static_cast<size_t>(level);
45 if (index >= LEVEL_NAMES.size())
48 return LEVEL_NAMES[index];
52 const auto index =
static_cast<size_t>(level);
53 if (index >= LEVEL_LETTERS.size())
56 return LEVEL_LETTERS[index];
60 for (
size_t i = 0; i < LEVEL_NAMES.size(); ++i) {
61 if (LEVEL_NAMES[i] != text)
64 level =
static_cast<Level>(i);
75 const size_t slash = path.find_last_of(
"/\\");
76 return slash == std::string_view::npos ? path : path.substr(slash + 1);
107 std::scoped_lock lock(
m_mutex);
108 m_sinks.push_back(std::move(sink));
112 std::scoped_lock lock(
m_mutex);
117 const chr::duration<double> elapsed = chr::steady_clock::now() -
m_startTime;
122 .location = location,
123 .elapsedSeconds = elapsed.count(),
126 std::scoped_lock lock(
m_mutex);
127 for (
const auto& sink :
m_sinks)
134 for (
const auto& sink :
m_sinks)
139 std::scoped_lock lock(
m_mutex);
140 for (
const auto& sink :
m_sinks)
void AddSink(std::unique_ptr< LogSink > sink)
void Write(Channel channel, Level level, std::string_view message, const std::source_location &location)
chr::steady_clock::time_point m_startTime
std::atomic< Level > m_minLevel
std::vector< std::unique_ptr< LogSink > > m_sinks
constexpr std::array< std::string_view, 6 > LEVEL_NAMES
constexpr std::string_view LEVEL_LETTERS
constexpr Level DEFAULT_MIN_LEVEL
constexpr std::array< std::string_view, static_cast< size_t >(Channel::Count)> CHANNEL_NAMES
char LevelLetter(Level level)
std::string_view ChannelName(Channel channel)
std::string_view FileNameOnly(std::string_view path)
std::string FormatLogLine(const LogRecord &record, bool withLocation)
std::string_view LevelName(Level level)
std::unique_ptr< LogSink > CreateConsoleSink()
std::unique_ptr< LogSink > CreateDebuggerSink()
bool ParseLevel(std::string_view text, Level &level)
std::source_location location