#1278: Allow forcing ansicolor sinks on Windows

pull/1279/head
Raul Tambre 6 years ago
parent 4858d7e454
commit f89cf97596

@ -67,6 +67,7 @@ option(SPDLOG_FMT_EXTERNAL "Use external fmt library instead of bundled" OFF)
if(WIN32)
option(SPDLOG_WCHAR_SUPPORT "Support wchar api" OFF)
option(SPDLOG_WCHAR_FILENAMES "Support wchar filenames" OFF)
option(SPDLOG_FORCE_ANSICOLOR "Use VT100 instead of winapi for colored sinks" OFF)
endif()
option(SPDLOG_NO_EXCEPTIONS "Compile with -fno-exceptions. Call abort() on any spdlog exceptions" OFF)
@ -150,6 +151,11 @@ if(SPDLOG_WCHAR_SUPPORT)
target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_WCHAR_FILENAMES)
endif()
if(WIN32 AND NOT SPDLOG_FORCE_ANSICOLOR)
target_compile_definitions(spdlog PUBLIC SPDLOG_WINCOLOR)
target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_WINCOLOR)
endif()
if(SPDLOG_NO_EXCEPTIONS)
target_compile_definitions(spdlog PUBLIC SPDLOG_NO_EXCEPTIONS)

@ -14,7 +14,7 @@
#ifndef SPDLOG_DISABLE_DEFAULT_LOGGER
// support for the default stdout color logger
#ifdef _WIN32
#ifdef SPDLOG_WINCOLOR
#include "spdlog/sinks/wincolor_sink.h"
#else
#include "spdlog/sinks/ansicolor_sink.h"
@ -36,7 +36,7 @@ SPDLOG_INLINE registry::registry()
#ifndef SPDLOG_DISABLE_DEFAULT_LOGGER
// create default logger (ansicolor_stdout_sink_mt or wincolor_stdout_sink_mt in windows).
#ifdef _WIN32
#ifdef SPDLOG_WINCOLOR
auto color_sink = std::make_shared<sinks::wincolor_stdout_sink_mt>();
#else
auto color_sink = std::make_shared<sinks::ansicolor_stdout_sink_mt>();

@ -3,7 +3,7 @@
#pragma once
#ifdef _WIN32
#ifdef SPDLOG_WINCOLOR
#include "spdlog/sinks/wincolor_sink.h"
#else
#include "spdlog/sinks/ansicolor_sink.h"
@ -13,7 +13,7 @@
namespace spdlog {
namespace sinks {
#ifdef _WIN32
#ifdef SPDLOG_WINCOLOR
using stdout_color_sink_mt = wincolor_stdout_sink_mt;
using stdout_color_sink_st = wincolor_stdout_sink_st;
using stderr_color_sink_mt = wincolor_stderr_sink_mt;

@ -12,7 +12,7 @@
//
// color sinks
//
#ifdef _WIN32
#ifdef SPDLOG_WINCOLOR
#include "spdlog/sinks/wincolor_sink-inl.h"
template class spdlog::sinks::wincolor_sink<spdlog::details::console_mutex>;
template class spdlog::sinks::wincolor_sink<spdlog::details::console_nullmutex>;

Loading…
Cancel
Save