|
|
|
@ -9,10 +9,10 @@
|
|
|
|
|
#include "../details/os.h"
|
|
|
|
|
#include "../details/traits.h"
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <mutex>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
|
|
namespace spdlog {
|
|
|
|
|
namespace sinks {
|
|
|
|
@ -28,11 +28,11 @@ namespace spdlog {
|
|
|
|
|
public:
|
|
|
|
|
using mutex_t = typename ConsoleMutexTrait::mutex_t;
|
|
|
|
|
ansicolor_sink()
|
|
|
|
|
: target_file_(StdoutTrait::stream()),
|
|
|
|
|
_mutex(ConsoleMutexTrait::mutex())
|
|
|
|
|
: target_file_(StdoutTrait::stream())
|
|
|
|
|
, _mutex(ConsoleMutexTrait::console_mutex())
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
should_do_colors_ = details::os::in_terminal(file) && details::os::is_color_terminal();
|
|
|
|
|
should_do_colors_ = details::os::in_terminal(target_file_) && details::os::is_color_terminal();
|
|
|
|
|
colors_[level::trace] = white;
|
|
|
|
|
colors_[level::debug] = cyan;
|
|
|
|
|
colors_[level::info] = green;
|
|
|
|
@ -42,10 +42,7 @@ namespace spdlog {
|
|
|
|
|
colors_[level::off] = reset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~ansicolor_sink() override
|
|
|
|
|
{
|
|
|
|
|
_flush();
|
|
|
|
|
}
|
|
|
|
|
~ansicolor_sink() override = default;
|
|
|
|
|
|
|
|
|
|
ansicolor_sink(const ansicolor_sink &other) = delete;
|
|
|
|
|
ansicolor_sink &operator=(const ansicolor_sink &other) = delete;
|
|
|
|
@ -86,7 +83,6 @@ namespace spdlog {
|
|
|
|
|
const std::string on_cyan = "\033[46m";
|
|
|
|
|
const std::string on_white = "\033[47m";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void log(const details::log_msg &msg) SPDLOG_FINAL override
|
|
|
|
|
{
|
|
|
|
|
// Wrap the originally formatted message in color codes.
|
|
|
|
@ -116,9 +112,7 @@ namespace spdlog {
|
|
|
|
|
fflush(target_file_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
void _print_ccode(const std::string &color_code)
|
|
|
|
|
{
|
|
|
|
|
fwrite(color_code.data(), sizeof(char), color_code.size(), target_file_);
|
|
|
|
|