• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright(c) 2016 Alexander Dalshov.
3 // Distributed under the MIT License (http://opensource.org/licenses/MIT)
4 //
5 
6 #pragma once
7 
8 #if defined(_MSC_VER)
9 
10 #include <spdlog/sinks/base_sink.h>
11 #include <spdlog/details/null_mutex.h>
12 
13 #include <WinBase.h>
14 
15 #include <mutex>
16 #include <string>
17 
18 namespace spdlog
19 {
20 namespace sinks
21 {
22 /*
23 * MSVC sink (logging using OutputDebugStringA)
24 */
25 template<class Mutex>
26 class msvc_sink : public base_sink < Mutex >
27 {
28 public:
msvc_sink()29     explicit msvc_sink()
30     {
31     }
32 
flush()33     void flush() override
34     {
35     }
36 
37 protected:
_sink_it(const details::log_msg & msg)38     void _sink_it(const details::log_msg& msg) override
39     {
40         OutputDebugStringA(msg.formatted.c_str());
41     }
42 };
43 
44 typedef msvc_sink<std::mutex> msvc_sink_mt;
45 typedef msvc_sink<details::null_mutex> msvc_sink_st;
46 
47 }
48 }
49 
50 #endif
51