From ee610efd7d27bd28da539b02e2a76ae7c37ab3b0 Mon Sep 17 00:00:00 2001 From: "Kevin M. Godby" Date: Fri, 18 Mar 2016 13:13:06 -0500 Subject: [PATCH] Add assignment operator to ansi color sink. Adjust default colors. --- include/spdlog/sinks/ansicolor_sink.h | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/include/spdlog/sinks/ansicolor_sink.h b/include/spdlog/sinks/ansicolor_sink.h index d3574171..0b79990b 100644 --- a/include/spdlog/sinks/ansicolor_sink.h +++ b/include/spdlog/sinks/ansicolor_sink.h @@ -24,6 +24,9 @@ public: ansicolor_sink(sink_ptr sink); virtual ~ansicolor_sink(); + ansicolor_sink(const ansicolor_sink& other); + ansicolor_sink& operator=(const ansicolor_sink& other); + virtual void log(const details::log_msg& msg) override; virtual void flush() override; @@ -72,10 +75,10 @@ protected: inline ansicolor_sink::ansicolor_sink(sink_ptr sink) : sink_(sink) { - colors_[level::trace] = grey; - colors_[level::debug] = grey; + colors_[level::trace] = white; + colors_[level::debug] = white; colors_[level::info] = white; - colors_[level::notice] = yellow; + colors_[level::notice] = bold + white; colors_[level::warn] = bold + yellow; colors_[level::err] = red; colors_[level::critical] = bold + red; @@ -89,6 +92,22 @@ inline ansicolor_sink::~ansicolor_sink() flush(); } +inline ansicolor_sink::ansicolor_sink(const ansicolor_sink& other) : sink_(other.sink_), colors_(other.colors_) +{ + // do nothing +} + + +inline ansicolor_sink& ansicolor_sink::operator=(const ansicolor_sink& other) +{ + if (this == &other) + return *this; + + sink_ = other.sink_; + colors_ = other.colors_; + return *this; +} + inline void ansicolor_sink::log(const details::log_msg& msg) { // Wrap the originally formatted message in color codes