mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-26 02:21:34 +08:00
Removed public color constants from wincolor sink and intensify red and yellow
This commit is contained in:
parent
3e689e700e
commit
e931866b35
@ -17,27 +17,25 @@ namespace spdlog {
|
||||
namespace sinks {
|
||||
template<typename ConsoleMutex>
|
||||
SPDLOG_INLINE wincolor_sink<ConsoleMutex>::wincolor_sink(void *out_handle, color_mode mode)
|
||||
: BOLD(FOREGROUND_INTENSITY)
|
||||
, RED(FOREGROUND_RED)
|
||||
, GREEN(FOREGROUND_GREEN)
|
||||
, CYAN(FOREGROUND_GREEN | FOREGROUND_BLUE)
|
||||
, WHITE(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE)
|
||||
, YELLOW(FOREGROUND_RED | FOREGROUND_GREEN)
|
||||
, out_handle_(out_handle)
|
||||
: out_handle_(out_handle)
|
||||
, mutex_(ConsoleMutex::mutex())
|
||||
, formatter_(details::make_unique<spdlog::pattern_formatter>())
|
||||
{
|
||||
|
||||
// check if out_handle is points to the actual console.
|
||||
// ::GetConsoleMode() should return 0 if it is redirected or not valid console handle.
|
||||
DWORD console_mode;
|
||||
in_console_ = ::GetConsoleMode(static_cast<HANDLE>(out_handle_), &console_mode) != 0;
|
||||
set_color_mode(mode);
|
||||
colors_[level::trace] = WHITE;
|
||||
colors_[level::debug] = CYAN;
|
||||
colors_[level::info] = GREEN;
|
||||
colors_[level::warn] = YELLOW | BOLD;
|
||||
colors_[level::err] = RED | BOLD; // red bold
|
||||
colors_[level::critical] = BACKGROUND_RED | WHITE | BOLD; // white bold on red background
|
||||
|
||||
// set level colors
|
||||
colors_[level::trace] = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; // white
|
||||
colors_[level::debug] = FOREGROUND_GREEN | FOREGROUND_BLUE; // cyan
|
||||
colors_[level::info] = FOREGROUND_GREEN; // green
|
||||
colors_[level::warn] = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; // intense yellow
|
||||
colors_[level::err] = FOREGROUND_RED | FOREGROUND_INTENSITY; // intense red
|
||||
colors_[level::critical] =
|
||||
BACKGROUND_RED | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; // intense white on red background
|
||||
colors_[level::off] = 0;
|
||||
}
|
||||
|
||||
@ -135,7 +133,7 @@ std::uint16_t SPDLOG_INLINE wincolor_sink<ConsoleMutex>::set_foreground_color_(s
|
||||
CONSOLE_SCREEN_BUFFER_INFO orig_buffer_info;
|
||||
if (!::GetConsoleScreenBufferInfo(static_cast<HANDLE>(out_handle_), &orig_buffer_info))
|
||||
{
|
||||
return WHITE;
|
||||
return FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; // white
|
||||
}
|
||||
|
||||
WORD back_color = orig_buffer_info.wAttributes;
|
||||
|
@ -24,13 +24,6 @@ template<typename ConsoleMutex>
|
||||
class wincolor_sink : public sink
|
||||
{
|
||||
public:
|
||||
const std::uint16_t BOLD;
|
||||
const std::uint16_t RED;
|
||||
const std::uint16_t GREEN;
|
||||
const std::uint16_t CYAN;
|
||||
const std::uint16_t WHITE;
|
||||
const std::uint16_t YELLOW;
|
||||
|
||||
wincolor_sink(void *out_handle, color_mode mode);
|
||||
~wincolor_sink() override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user