1
0
mirror of synced 2024-09-24 11:38:26 +02:00

impr: Nicer looking logger output colors

This commit is contained in:
WerWolv 2024-02-24 11:28:47 +01:00
parent 2049852a80
commit 3c365d65a4
2 changed files with 25 additions and 5 deletions

View File

@ -49,6 +49,16 @@ namespace hex::log {
addLogEntry(IMHEX_PROJECT_NAME, level, std::move(message));
}
namespace color {
fmt::color debug();
fmt::color info();
fmt::color warn();
fmt::color error();
fmt::color fatal();
}
}
void suspendLogging();
@ -56,26 +66,26 @@ namespace hex::log {
[[maybe_unused]] void debug(const std::string &fmt, auto && ... args) {
#if defined(DEBUG)
hex::log::impl::print(fg(fmt::color::light_green) | fmt::emphasis::bold, "[DEBUG]", fmt, args...);
hex::log::impl::print(fg(impl::color::debug()) | fmt::emphasis::bold, "[DEBUG]", fmt, args...);
#else
impl::addLogEntry(IMHEX_PROJECT_NAME, "[DEBUG]", fmt::format(fmt::runtime(fmt), args...));
#endif
}
[[maybe_unused]] void info(const std::string &fmt, auto && ... args) {
hex::log::impl::print(fg(fmt::color::cadet_blue) | fmt::emphasis::bold, "[INFO] ", fmt, args...);
hex::log::impl::print(fg(impl::color::info()) | fmt::emphasis::bold, "[INFO] ", fmt, args...);
}
[[maybe_unused]] void warn(const std::string &fmt, auto && ... args) {
hex::log::impl::print(fg(fmt::color::orange) | fmt::emphasis::bold, "[WARN] ", fmt, args...);
hex::log::impl::print(fg(impl::color::warn()) | fmt::emphasis::bold, "[WARN] ", fmt, args...);
}
[[maybe_unused]] void error(const std::string &fmt, auto && ... args) {
hex::log::impl::print(fg(fmt::color::red) | fmt::emphasis::bold, "[ERROR]", fmt, args...);
hex::log::impl::print(fg(impl::color::error()) | fmt::emphasis::bold, "[ERROR]", fmt, args...);
}
[[maybe_unused]] void fatal(const std::string &fmt, auto && ... args) {
hex::log::impl::print(fg(fmt::color::purple) | fmt::emphasis::bold, "[FATAL]", fmt, args...);
hex::log::impl::print(fg(impl::color::fatal()) | fmt::emphasis::bold, "[FATAL]", fmt, args...);
}

View File

@ -131,6 +131,16 @@ namespace hex::log {
}
}
namespace color {
fmt::color debug() { return fmt::color::medium_sea_green; }
fmt::color info() { return fmt::color::steel_blue; }
fmt::color warn() { return fmt::color::orange; }
fmt::color error() { return fmt::color::indian_red; }
fmt::color fatal() { return fmt::color::medium_purple; }
}
}
}