1#pragma once
2//
3// Copyright(c) 2018 Gabi Melman.
4// Distributed under the MIT License (http://opensource.org/licenses/MIT)
5//
6
7#include "spdlog/details/null_mutex.h"
8#include <cstdio>
9#include <mutex>
10
11namespace spdlog {
12namespace details {
13struct console_stdout
14{
15    static std::FILE *stream()
16    {
17        return stdout;
18    }
19#ifdef _WIN32
20    static HANDLE handle()
21    {
22        return ::GetStdHandle(STD_OUTPUT_HANDLE);
23    }
24#endif
25};
26
27struct console_stderr
28{
29    static std::FILE *stream()
30    {
31        return stderr;
32    }
33#ifdef _WIN32
34    static HANDLE handle()
35    {
36        return ::GetStdHandle(STD_ERROR_HANDLE);
37    }
38#endif
39};
40
41struct console_mutex
42{
43    using mutex_t = std::mutex;
44    static mutex_t &mutex()
45    {
46        static mutex_t s_mutex;
47        return s_mutex;
48    }
49};
50
51struct console_nullmutex
52{
53    using mutex_t = null_mutex;
54    static mutex_t &mutex()
55    {
56        static mutex_t s_mutex;
57        return s_mutex;
58    }
59};
60} // namespace details
61} // namespace spdlog
62