mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 10:01:33 +08:00
Renamed to level_to_number
This commit is contained in:
parent
433cac487e
commit
9a7448e4c8
@ -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<size_t>(lvl);
|
||||
}
|
||||
constexpr auto levels_count = to_size_t(level::n_levels);
|
||||
constexpr auto levels_count = level_to_number(level::n_levels);
|
||||
constexpr std::array<string_view_t, levels_count> level_string_views SPDLOG_LEVEL_NAMES;
|
||||
constexpr std::array<const char *, levels_count> 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;
|
||||
|
@ -21,20 +21,20 @@ SPDLOG_INLINE ansicolor_sink<ConsoleMutex>::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<typename ConsoleMutex>
|
||||
SPDLOG_INLINE void ansicolor_sink<ConsoleMutex>::set_color(level color_level, string_view_t color)
|
||||
{
|
||||
std::lock_guard<mutex_t> lock(mutex_);
|
||||
colors_.at(to_size_t(color_level)) = to_string_(color);
|
||||
colors_.at(level_to_number(color_level)) = to_string_(color);
|
||||
}
|
||||
|
||||
template<typename ConsoleMutex>
|
||||
|
@ -24,14 +24,14 @@ SPDLOG_INLINE wincolor_sink<ConsoleMutex>::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<typename ConsoleMutex>
|
||||
|
Loading…
Reference in New Issue
Block a user