mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-26 18:41:35 +08:00
Use std::string_view in level names and ansicolor_sink.h
This commit is contained in:
parent
c122eaf749
commit
d94311ad6b
@ -158,15 +158,15 @@ using atomic_level_t = std::atomic<level>;
|
||||
[[nodiscard]] constexpr size_t level_to_number(level lvl) noexcept { return static_cast<size_t>(lvl); }
|
||||
|
||||
constexpr auto levels_count = level_to_number(level::n_levels);
|
||||
constexpr std::array<string_view_t, levels_count> level_string_views{"trace", "debug", "info", "warning",
|
||||
constexpr std::array<std::string_view, levels_count> level_string_views{"trace", "debug", "info", "warning",
|
||||
"error", "critical", "off"};
|
||||
constexpr std::array<string_view_t, levels_count> short_level_names{"T", "D", "I", "W", "E", "C", "O"};
|
||||
constexpr std::array<std::string_view, levels_count> short_level_names{"T", "D", "I", "W", "E", "C", "O"};
|
||||
|
||||
[[nodiscard]] constexpr string_view_t to_string_view(spdlog::level lvl) noexcept {
|
||||
[[nodiscard]] constexpr std::string_view to_string_view(spdlog::level lvl) noexcept {
|
||||
return level_string_views.at(level_to_number(lvl));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr const string_view_t to_short_string_view(spdlog::level lvl) noexcept {
|
||||
[[nodiscard]] constexpr const std::string_view to_short_string_view(spdlog::level lvl) noexcept {
|
||||
return short_level_names.at(level_to_number(lvl));
|
||||
}
|
||||
|
||||
|
@ -35,39 +35,39 @@ public:
|
||||
bool should_color();
|
||||
|
||||
// Formatting codes
|
||||
static constexpr spdlog::string_view_t reset = "\033[m";
|
||||
static constexpr spdlog::string_view_t bold = "\033[1m";
|
||||
static constexpr spdlog::string_view_t dark = "\033[2m";
|
||||
static constexpr spdlog::string_view_t underline = "\033[4m";
|
||||
static constexpr spdlog::string_view_t blink = "\033[5m";
|
||||
static constexpr spdlog::string_view_t reverse = "\033[7m";
|
||||
static constexpr spdlog::string_view_t concealed = "\033[8m";
|
||||
static constexpr spdlog::string_view_t clear_line = "\033[K";
|
||||
static constexpr std::string_view reset = "\033[m";
|
||||
static constexpr std::string_view bold = "\033[1m";
|
||||
static constexpr std::string_view dark = "\033[2m";
|
||||
static constexpr std::string_view underline = "\033[4m";
|
||||
static constexpr std::string_view blink = "\033[5m";
|
||||
static constexpr std::string_view reverse = "\033[7m";
|
||||
static constexpr std::string_view concealed = "\033[8m";
|
||||
static constexpr std::string_view clear_line = "\033[K";
|
||||
|
||||
// Foreground colors
|
||||
static constexpr spdlog::string_view_t black = "\033[30m";
|
||||
static constexpr spdlog::string_view_t red = "\033[31m";
|
||||
static constexpr spdlog::string_view_t green = "\033[32m";
|
||||
static constexpr spdlog::string_view_t yellow = "\033[33m";
|
||||
static constexpr spdlog::string_view_t blue = "\033[34m";
|
||||
static constexpr spdlog::string_view_t magenta = "\033[35m";
|
||||
static constexpr spdlog::string_view_t cyan = "\033[36m";
|
||||
static constexpr spdlog::string_view_t white = "\033[37m";
|
||||
static constexpr std::string_view black = "\033[30m";
|
||||
static constexpr std::string_view red = "\033[31m";
|
||||
static constexpr std::string_view green = "\033[32m";
|
||||
static constexpr std::string_view yellow = "\033[33m";
|
||||
static constexpr std::string_view blue = "\033[34m";
|
||||
static constexpr std::string_view magenta = "\033[35m";
|
||||
static constexpr std::string_view cyan = "\033[36m";
|
||||
static constexpr std::string_view white = "\033[37m";
|
||||
|
||||
// Background colors
|
||||
static constexpr spdlog::string_view_t on_black = "\033[40m";
|
||||
static constexpr spdlog::string_view_t on_red = "\033[41m";
|
||||
static constexpr spdlog::string_view_t on_green = "\033[42m";
|
||||
static constexpr spdlog::string_view_t on_yellow = "\033[43m";
|
||||
static constexpr spdlog::string_view_t on_blue = "\033[44m";
|
||||
static constexpr spdlog::string_view_t on_magenta = "\033[45m";
|
||||
static constexpr spdlog::string_view_t on_cyan = "\033[46m";
|
||||
static constexpr spdlog::string_view_t on_white = "\033[47m";
|
||||
static constexpr std::string_view on_black = "\033[40m";
|
||||
static constexpr std::string_view on_red = "\033[41m";
|
||||
static constexpr std::string_view on_green = "\033[42m";
|
||||
static constexpr std::string_view on_yellow = "\033[43m";
|
||||
static constexpr std::string_view on_blue = "\033[44m";
|
||||
static constexpr std::string_view on_magenta = "\033[45m";
|
||||
static constexpr std::string_view on_cyan = "\033[46m";
|
||||
static constexpr std::string_view on_white = "\033[47m";
|
||||
|
||||
// Bold colors
|
||||
static constexpr spdlog::string_view_t yellow_bold = "\033[33m\033[1m";
|
||||
static constexpr spdlog::string_view_t red_bold = "\033[31m\033[1m";
|
||||
static constexpr spdlog::string_view_t bold_on_red = "\033[1m\033[41m";
|
||||
static constexpr std::string_view yellow_bold = "\033[33m\033[1m";
|
||||
static constexpr std::string_view red_bold = "\033[31m\033[1m";
|
||||
static constexpr std::string_view bold_on_red = "\033[1m\033[41m";
|
||||
|
||||
private:
|
||||
void sink_it_(const details::log_msg &msg) override;
|
||||
|
Loading…
Reference in New Issue
Block a user