Livox SDK API  V2.2.0
msvc_sink.h
Go to the documentation of this file.
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 #ifndef SPDLOG_H
9 #include "spdlog/spdlog.h"
10 #endif
11 
12 #if defined(_WIN32)
13 
15 #include "spdlog/sinks/base_sink.h"
16 
17 #include <winbase.h>
18 
19 #include <mutex>
20 #include <string>
21 
22 namespace spdlog {
23 namespace sinks {
24 /*
25  * MSVC sink (logging using OutputDebugStringA)
26  */
27 template<typename Mutex>
28 class msvc_sink : public base_sink<Mutex>
29 {
30 public:
31  explicit msvc_sink() {}
32 
33 protected:
34  void sink_it_(const details::log_msg &msg) override
35  {
36 
37  fmt::memory_buffer formatted;
38  sink::formatter_->format(msg, formatted);
39  OutputDebugStringA(fmt::to_string(formatted).c_str());
40  }
41 
42  void flush_() override {}
43 };
44 
45 using msvc_sink_mt = msvc_sink<std::mutex>;
46 using msvc_sink_st = msvc_sink<details::null_mutex>;
47 
48 using windebug_sink_mt = msvc_sink_mt;
49 using windebug_sink_st = msvc_sink_st;
50 
51 } // namespace sinks
52 } // namespace spdlog
53 
54 #endif
std::unique_ptr< spdlog::formatter > formatter_
Definition: sink.h:50
Definition: async.h:27
std::string to_string(const T &value)
Definition: format.h:3209