mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-31 17:49:13 +08:00
66 lines
1.0 KiB
C++
66 lines
1.0 KiB
C++
#pragma once
|
|
//
|
|
// Copyright(c) 2018 Gabi Melman.
|
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
//
|
|
|
|
#include "spdlog/details/null_mutex.h"
|
|
#include <cstdio>
|
|
#include <mutex>
|
|
|
|
#ifdef _WIN32
|
|
#include "spdlog/details/os.h"
|
|
#endif
|
|
|
|
namespace spdlog {
|
|
namespace details {
|
|
struct console_stdout
|
|
{
|
|
static std::FILE *stream()
|
|
{
|
|
return stdout;
|
|
}
|
|
#ifdef _WIN32
|
|
static HANDLE handle()
|
|
{
|
|
return ::GetStdHandle(STD_OUTPUT_HANDLE);
|
|
}
|
|
#endif
|
|
};
|
|
|
|
struct console_stderr
|
|
{
|
|
static std::FILE *stream()
|
|
{
|
|
return stderr;
|
|
}
|
|
#ifdef _WIN32
|
|
static HANDLE handle()
|
|
{
|
|
return ::GetStdHandle(STD_ERROR_HANDLE);
|
|
}
|
|
#endif
|
|
};
|
|
|
|
struct console_mutex
|
|
{
|
|
using mutex_t = std::mutex;
|
|
static mutex_t &mutex()
|
|
{
|
|
static mutex_t s_mutex;
|
|
return s_mutex;
|
|
}
|
|
};
|
|
|
|
struct console_nullmutex
|
|
{
|
|
using mutex_t = null_mutex;
|
|
static mutex_t &mutex()
|
|
{
|
|
static mutex_t s_mutex;
|
|
return s_mutex;
|
|
}
|
|
};
|
|
} // namespace details
|
|
} // namespace spdlog
|