diff options
Diffstat (limited to 'src/zencore/logging.cpp')
| -rw-r--r-- | src/zencore/logging.cpp | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/zencore/logging.cpp b/src/zencore/logging.cpp index 5ada0cac7..3ec614da1 100644 --- a/src/zencore/logging.cpp +++ b/src/zencore/logging.cpp @@ -26,7 +26,7 @@ namespace { // Bootstrap logger: a minimal stdout logger that exists for the entire lifetime // of the process. TheDefaultLogger points here before InitializeLogging() runs // (and is restored here after ShutdownLogging()) so that log macros always have -// a usable target — no null checks or lazy init required on the common path. +// a usable target - no null checks or lazy init required on the common path. zen::Ref<zen::logging::Logger> s_BootstrapLogger = [] { zen::logging::SinkPtr Sink(new zen::logging::AnsiColorStdoutSink()); return zen::Ref<zen::logging::Logger>(new zen::logging::Logger("", Sink)); @@ -112,6 +112,14 @@ constinit std::string_view LevelNames[] = {std::string_view("trace", 5), std::string_view("critical", 8), std::string_view("off", 3)}; +constinit std::string_view ShortNames[] = {std::string_view("trc", 3), + std::string_view("dbg", 3), + std::string_view("inf", 3), + std::string_view("wrn", 3), + std::string_view("err", 3), + std::string_view("crt", 3), + std::string_view("off", 3)}; + LogLevel ParseLogLevelString(std::string_view Name) { @@ -137,14 +145,29 @@ ParseLogLevelString(std::string_view Name) } std::string_view -ToStringView(LogLevel Level) +ToString(LogLevel Level) { + using namespace std::literals; + if (int(Level) < LogLevelCount) { return LevelNames[int(Level)]; } - return "None"; + return "None"sv; +} + +std::string_view +ShortToString(LogLevel Level) +{ + using namespace std::literals; + + if (int(Level) < LogLevelCount) + { + return ShortNames[int(Level)]; + } + + return "None"sv; } } // namespace zen::logging @@ -476,6 +499,10 @@ LoggerRef::LoggerRef(logging::Logger& InLogger) : m_Logger(static_cast<logging:: { } +LoggerRef::LoggerRef(std::string_view LogCategory) : m_Logger(zen::logging::Get(LogCategory).m_Logger) +{ +} + void LoggerRef::Flush() { |