Merge pull request #2443 from ibmibmibm/v1.x

Explicitly casting level_enum to size_t.
This commit is contained in:
Gabi Melman 2022-07-22 18:52:02 +03:00 committed by GitHub
commit 7d805c2231
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,7 +45,7 @@ template<typename ConsoleMutex>
void SPDLOG_INLINE wincolor_sink<ConsoleMutex>::set_color(level::level_enum level, std::uint16_t color) void SPDLOG_INLINE wincolor_sink<ConsoleMutex>::set_color(level::level_enum level, std::uint16_t color)
{ {
std::lock_guard<mutex_t> lock(mutex_); std::lock_guard<mutex_t> lock(mutex_);
colors_[level] = color; colors_[static_cast<size_t>(level)] = color;
} }
template<typename ConsoleMutex> template<typename ConsoleMutex>
@ -66,7 +66,7 @@ void SPDLOG_INLINE wincolor_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
auto orig_attribs = static_cast<WORD>(set_foreground_color_(colors_[msg.level])); auto orig_attribs = static_cast<WORD>(set_foreground_color_(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);
// reset to orig colors // reset to orig colors
::SetConsoleTextAttribute(static_cast<HANDLE>(out_handle_), orig_attribs); ::SetConsoleTextAttribute(static_cast<HANDLE>(out_handle_), orig_attribs);