Merge pull request #2245 from daverigby/level_enum_fwd

Allow forward-declaration of level_enum
This commit is contained in:
Gabi Melman 2022-01-11 18:59:42 +02:00 committed by GitHub
commit 4cfdc8c5c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -208,7 +208,7 @@ using level_t = std::atomic<int>;
// Log level enum // Log level enum
namespace level { namespace level {
enum level_enum enum level_enum : int
{ {
trace = SPDLOG_LEVEL_TRACE, trace = SPDLOG_LEVEL_TRACE,
debug = SPDLOG_LEVEL_DEBUG, debug = SPDLOG_LEVEL_DEBUG,

View File

@ -11,4 +11,8 @@ namespace sinks {
class sink; class sink;
} }
namespace level {
enum level_enum : int;
}
} // namespace spdlog } // namespace spdlog

View File

@ -34,7 +34,7 @@ template<typename ConsoleMutex>
SPDLOG_INLINE void ansicolor_sink<ConsoleMutex>::set_color(level::level_enum color_level, string_view_t color) SPDLOG_INLINE void ansicolor_sink<ConsoleMutex>::set_color(level::level_enum color_level, string_view_t color)
{ {
std::lock_guard<mutex_t> lock(mutex_); std::lock_guard<mutex_t> lock(mutex_);
colors_[color_level] = to_string_(color); colors_[static_cast<size_t>(color_level)] = to_string_(color);
} }
template<typename ConsoleMutex> template<typename ConsoleMutex>
@ -52,7 +52,7 @@ SPDLOG_INLINE void ansicolor_sink<ConsoleMutex>::log(const details::log_msg &msg
// before color range // before color range
print_range_(formatted, 0, msg.color_range_start); print_range_(formatted, 0, msg.color_range_start);
// in color range // in color range
print_ccode_(colors_[msg.level]); print_ccode_(colors_[static_cast<size_t>(msg.level)]);
print_range_(formatted, msg.color_range_start, msg.color_range_end); print_range_(formatted, msg.color_range_start, msg.color_range_end);
print_ccode_(reset); print_ccode_(reset);
// after color range // after color range