source: trunk/GDE/SINA/builddir/include/spdlog/sinks/msvc_sink.h

Last change on this file was 19170, checked in by westram, 2 years ago
  • sina source
    • unpack + remove tarball
    • no longer ignore sina builddir.
File size: 1.0 KB
Line 
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
14#include "spdlog/details/null_mutex.h"
15#include "spdlog/sinks/base_sink.h"
16
17#include <winbase.h>
18
19#include <mutex>
20#include <string>
21
22namespace spdlog {
23namespace sinks {
24/*
25 * MSVC sink (logging using OutputDebugStringA)
26 */
27template<typename Mutex>
28class msvc_sink : public base_sink<Mutex>
29{
30public:
31    explicit msvc_sink() {}
32
33protected:
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
45using msvc_sink_mt = msvc_sink<std::mutex>;
46using msvc_sink_st = msvc_sink<details::null_mutex>;
47
48using windebug_sink_mt = msvc_sink_mt;
49using windebug_sink_st = msvc_sink_st;
50
51} // namespace sinks
52} // namespace spdlog
53
54#endif
Note: See TracBrowser for help on using the repository browser.