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 
11 namespace spdlog {
12 namespace details {
13 struct console_stdout
14 {
streamspdlog::details::console_stdout15     static std::FILE *stream()
16     {
17         return stdout;
18     }
19 #ifdef _WIN32
handlespdlog::details::console_stdout20     static HANDLE handle()
21     {
22         return ::GetStdHandle(STD_OUTPUT_HANDLE);
23     }
24 #endif
25 };
26 
27 struct console_stderr
28 {
streamspdlog::details::console_stderr29     static std::FILE *stream()
30     {
31         return stderr;
32     }
33 #ifdef _WIN32
handlespdlog::details::console_stderr34     static HANDLE handle()
35     {
36         return ::GetStdHandle(STD_ERROR_HANDLE);
37     }
38 #endif
39 };
40 
41 struct console_mutex
42 {
43     using mutex_t = std::mutex;
mutexspdlog::details::console_mutex44     static mutex_t &mutex()
45     {
46         static mutex_t s_mutex;
47         return s_mutex;
48     }
49 };
50 
51 struct console_nullmutex
52 {
53     using mutex_t = null_mutex;
mutexspdlog::details::console_nullmutex54     static mutex_t &mutex()
55     {
56         static mutex_t s_mutex;
57         return s_mutex;
58     }
59 };
60 } // namespace details
61 } // namespace spdlog
62