diff options
| author | Stefan Boberg <[email protected]> | 2025-08-26 14:53:31 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2025-08-26 14:53:31 +0200 |
| commit | 71b9f80cc72fae4cf0476bfca1646ec8311c9272 (patch) | |
| tree | 59c1e0b8911814445e6b78005a43207593393323 /src/zencore | |
| parent | default Sentry to off in debug (diff) | |
| parent | Merge branch 'main' into sb/zen-master (diff) | |
| download | zen-71b9f80cc72fae4cf0476bfca1646ec8311c9272.tar.xz zen-71b9f80cc72fae4cf0476bfca1646ec8311c9272.zip | |
Merge branch 'sb/zen-master' of https://github.ol.epicgames.net/ue-foundation/zen into sb/zen-master
Diffstat (limited to 'src/zencore')
| -rw-r--r-- | src/zencore/include/zencore/logging.h | 1 | ||||
| -rw-r--r-- | src/zencore/logging.cpp | 23 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/zencore/include/zencore/logging.h b/src/zencore/include/zencore/logging.h index bffbe84b4..afbbbd3ee 100644 --- a/src/zencore/include/zencore/logging.h +++ b/src/zencore/include/zencore/logging.h @@ -59,7 +59,6 @@ struct LogCategory zen::LoggerRef LoggerRef; }; -void EmitConsoleLogMessage(int LogLevel, std::string_view Message); void EmitConsoleLogMessage(int LogLevel, std::string_view Format, fmt::format_args Args); void EmitLogMessage(LoggerRef& Logger, int LogLevel, std::string_view Message); void EmitLogMessage(LoggerRef& Logger, const SourceLocation& Location, int LogLevel, std::string_view Message); diff --git a/src/zencore/logging.cpp b/src/zencore/logging.cpp index 5885587ad..685c79d82 100644 --- a/src/zencore/logging.cpp +++ b/src/zencore/logging.cpp @@ -122,11 +122,34 @@ EmitConsoleLogMessage(int LogLevel, const std::string_view Message) ConsoleLog().SpdLogger->log(InLevel, Message); } +#define ZEN_COLOR_YELLOW "\033[0;33m" +#define ZEN_COLOR_RED "\033[0;31m" +#define ZEN_BRIGHT_COLOR_RED "\033[1;31m" +#define ZEN_COLOR_RESET "\033[0m" + void EmitConsoleLogMessage(int LogLevel, std::string_view Format, fmt::format_args Args) { ZEN_MEMSCOPE(ELLMTag::Logging); zen::logging::LoggingContext LogCtx; + + // We are not using a format option for console which include log level since it would interfere with normal console output + + const spdlog::level::level_enum InLevel = (spdlog::level::level_enum)LogLevel; + switch (InLevel) + { + case spdlog::level::level_enum::warn: + fmt::format_to(fmt::appender(LogCtx.MessageBuffer), ZEN_COLOR_YELLOW "Warning: " ZEN_COLOR_RESET); + break; + case spdlog::level::level_enum::err: + fmt::format_to(fmt::appender(LogCtx.MessageBuffer), ZEN_BRIGHT_COLOR_RED "Error: " ZEN_COLOR_RESET); + break; + case spdlog::level::level_enum::critical: + fmt::format_to(fmt::appender(LogCtx.MessageBuffer), ZEN_COLOR_RED "Critical: " ZEN_COLOR_RESET); + break; + default: + break; + } fmt::vformat_to(fmt::appender(LogCtx.MessageBuffer), Format, Args); zen::logging::EmitConsoleLogMessage(LogLevel, LogCtx.Message()); } |