diff --git a/src/nba/include/nba/log.hpp b/src/nba/include/nba/log.hpp index e2beff45..505d2d92 100644 --- a/src/nba/include/nba/log.hpp +++ b/src/nba/include/nba/log.hpp @@ -8,6 +8,7 @@ #pragma once #include +#include #include #include #include @@ -38,16 +39,35 @@ namespace detail { template inline void Log(std::string_view format, Args&&... args) { if constexpr((detail::kLogMask & level) != 0) { + fmt::text_style style = {}; char const* prefix = "[?]"; - if constexpr(level == Trace) prefix = "\e[36m[T]"; - if constexpr(level == Debug) prefix = "\e[34m[D]"; - if constexpr(level == Info) prefix = "\e[37m[I]"; - if constexpr(level == Warn) prefix = "\e[33m[W]"; - if constexpr(level == Error) prefix = "\e[35m[E]"; - if constexpr(level == Fatal) prefix = "\e[31m[F]"; + if constexpr(level == Trace) { + style = fmt::fg(fmt::terminal_color::cyan); + prefix = "[T]"; + } + if constexpr(level == Debug) { + style = fmt::fg(fmt::terminal_color::blue); + prefix = "[D]"; + } + if constexpr(level == Info) { + prefix = "[I]"; + } + if constexpr(level == Warn) { + style = fmt::fg(fmt::terminal_color::yellow); + prefix = "[W]"; + } + if constexpr(level == Error) { + style = fmt::fg(fmt::terminal_color::magenta); + prefix = "[E]"; + } + if constexpr(level == Fatal) { + style = fmt::fg(fmt::terminal_color::red); + prefix = "[F]"; + } - fmt::print("{} {}\n", prefix, fmt::format(format, std::forward(args)...)); + const auto& style_ref = style; + fmt::print(style_ref, "{} {}\n", prefix, fmt::format(format, std::forward(args)...)); } }