spdlog/include/spdlog/details/traits.h

47 lines
888 B
C
Raw Normal View History

#pragma once
//
// Copyright(c) 2018 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
2018-04-19 22:50:18 +08:00
#include "stdio.h"
namespace spdlog {
namespace details {
struct console_stdout_trait
{
static FILE* stream() {return stdout;}
#ifdef _WIN32
static HANDLE handle() { return ::GetStdHandle(STD_OUTPUT_HANDLE); }
#endif
};
struct console_stderr_trait
{
static FILE* stream() { return stdout; }
#ifdef _WIN32
static HANDLE handle() { return ::GetStdHandle(STD_ERROR_HANDLE); }
#endif
};
struct console_mutex_trait
{
using mutex_t = std::mutex;
static mutex_t& console_mutex()
{
2018-04-19 23:41:00 +08:00
static auto &mutex = mutex_t{};
return mutex;
}
};
struct console_null_mutex_trait
{
using mutex_t = null_mutex;
static mutex_t& console_mutex()
{
static auto mutex = mutex_t{};
return mutex;
}
};
}
}