From 9a7448e4c8d87a0c54295d99019b3e5828188ab9 Mon Sep 17 00:00:00 2001 From: gabime Date: Sat, 23 Sep 2023 18:21:27 +0300 Subject: [PATCH] Renamed to level_to_number --- include/spdlog/common.h | 8 ++++---- include/spdlog/sinks/ansicolor_sink-inl.h | 16 ++++++++-------- include/spdlog/sinks/wincolor_sink-inl.h | 14 +++++++------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/spdlog/common.h b/include/spdlog/common.h index 59d3084e..57c18804 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -186,22 +186,22 @@ enum class level #define SPDLOG_SHORT_LEVEL_NAMES {"T", "D", "I", "W", "E", "C", "O"} #endif -constexpr size_t to_size_t(level lvl) noexcept +constexpr size_t level_to_number(level lvl) noexcept { return static_cast(lvl); } -constexpr auto levels_count = to_size_t(level::n_levels); +constexpr auto levels_count = level_to_number(level::n_levels); constexpr std::array level_string_views SPDLOG_LEVEL_NAMES; constexpr std::array short_level_names SPDLOG_SHORT_LEVEL_NAMES; constexpr string_view_t to_string_view(spdlog::level lvl) noexcept { - return level_string_views.at(to_size_t(lvl)); + return level_string_views.at(level_to_number(lvl)); } constexpr const char *to_short_c_str(spdlog::level lvl) noexcept { - return short_level_names.at(to_size_t(lvl)); + return short_level_names.at(level_to_number(lvl)); } SPDLOG_API spdlog::level level_from_str(const std::string &name) noexcept; diff --git a/include/spdlog/sinks/ansicolor_sink-inl.h b/include/spdlog/sinks/ansicolor_sink-inl.h index 9289b49a..6de548e2 100644 --- a/include/spdlog/sinks/ansicolor_sink-inl.h +++ b/include/spdlog/sinks/ansicolor_sink-inl.h @@ -21,20 +21,20 @@ SPDLOG_INLINE ansicolor_sink::ansicolor_sink(FILE *target_file, co { set_color_mode(mode); - colors_.at(to_size_t(level::trace)) = to_string_(white); - colors_.at(to_size_t(level::debug)) = to_string_(cyan); - colors_.at(to_size_t(level::info)) = to_string_(green); - colors_.at(to_size_t(level::warn)) = to_string_(yellow_bold); - colors_.at(to_size_t(level::err)) = to_string_(red_bold); - colors_.at(to_size_t(level::critical)) = to_string_(bold_on_red); - colors_.at(to_size_t(level::off)) = to_string_(reset); + colors_.at(level_to_number(level::trace)) = to_string_(white); + colors_.at(level_to_number(level::debug)) = to_string_(cyan); + colors_.at(level_to_number(level::info)) = to_string_(green); + colors_.at(level_to_number(level::warn)) = to_string_(yellow_bold); + colors_.at(level_to_number(level::err)) = to_string_(red_bold); + colors_.at(level_to_number(level::critical)) = to_string_(bold_on_red); + colors_.at(level_to_number(level::off)) = to_string_(reset); } template SPDLOG_INLINE void ansicolor_sink::set_color(level color_level, string_view_t color) { std::lock_guard lock(mutex_); - colors_.at(to_size_t(color_level)) = to_string_(color); + colors_.at(level_to_number(color_level)) = to_string_(color); } template diff --git a/include/spdlog/sinks/wincolor_sink-inl.h b/include/spdlog/sinks/wincolor_sink-inl.h index acffe2b6..da56cdc9 100644 --- a/include/spdlog/sinks/wincolor_sink-inl.h +++ b/include/spdlog/sinks/wincolor_sink-inl.h @@ -24,14 +24,14 @@ SPDLOG_INLINE wincolor_sink::wincolor_sink(void *out_handle, color set_color_mode_impl(mode); // set level colors - colors_.at(to_size_t(level::trace)) = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; // white - colors_.at(to_size_t(level::debug)) = FOREGROUND_GREEN | FOREGROUND_BLUE; // cyan - colors_.at(to_size_t(level::info)) = FOREGROUND_GREEN; // green - colors_.at(to_size_t(spdlog::level::warn)) = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; // intense yellow - colors_.at(to_size_t(level::err)) = FOREGROUND_RED | FOREGROUND_INTENSITY; // intense red - colors_.at(to_size_t(level::critical)) = + colors_.at(level_to_number(level::trace)) = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; // white + colors_.at(level_to_number(level::debug)) = FOREGROUND_GREEN | FOREGROUND_BLUE; // cyan + colors_.at(level_to_number(level::info)) = FOREGROUND_GREEN; // green + colors_.at(level_to_number(spdlog::level::warn)) = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; // intense yellow + colors_.at(level_to_number(level::err)) = FOREGROUND_RED | FOREGROUND_INTENSITY; // intense red + colors_.at(level_to_number(level::critical)) = BACKGROUND_RED | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; // intense white on red background - colors_.at(to_size_t(level::off)) = 0; + colors_.at(level_to_number(level::off)) = 0; } template