Photon 1.0.0
Loading...
Searching...
No Matches
base_sink.h
Go to the documentation of this file.
1// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
2// Distributed under the MIT License (http://opensource.org/licenses/MIT)
3
4#pragma once
5//
6// base sink templated over a mutex (either dummy or real)
7// concrete implementation should override the sink_it_() and flush_() methods.
8// locking is taken care of in this class - no locking needed by the
9// implementers..
10//
11
12#include <spdlog/common.h>
14#include <spdlog/sinks/sink.h>
15
16namespace spdlog
17{
18 namespace sinks
19 {
20 template <typename Mutex>
21 class SPDLOG_API base_sink : public sink
22 {
23 public:
24 base_sink();
25 explicit base_sink(std::unique_ptr<spdlog::formatter> formatter);
26 ~base_sink() override = default;
27
28 base_sink(const base_sink&) = delete;
29 base_sink(base_sink&&) = delete;
30
31 base_sink& operator=(const base_sink&) = delete;
33
34 void log(const details::log_msg& msg) final;
35 void flush() final;
36 void set_pattern(const std::string& pattern) final;
37 void set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) final;
38
39 protected:
40 // sink formatter
41 std::unique_ptr<spdlog::formatter> formatter_;
42 Mutex mutex_;
43
44 virtual void sink_it_(const details::log_msg& msg) = 0;
45 virtual void flush_() = 0;
46 virtual void set_pattern_(const std::string& pattern);
47 virtual void set_formatter_(std::unique_ptr<spdlog::formatter> sink_formatter);
48 };
49 } // namespace sinks
50} // namespace spdlog
51
52#ifdef SPDLOG_HEADER_ONLY
53#include "base_sink-inl.h"
54#endif
Definition formatter.h:13
Definition base_sink.h:22
base_sink & operator=(const base_sink &)=delete
base_sink & operator=(base_sink &&)=delete
base_sink(const base_sink &)=delete
base_sink(base_sink &&)=delete
~base_sink() override=default
Definition sink.h:15
#define SPDLOG_API
Definition common.h:45
Definition async.h:26
void log(source_loc source, level::level_enum lvl, format_string_t< Args... > fmt, Args &&... args)
Definition spdlog.h:145
Definition uuid.h:926
Definition log_msg.h:14
annotation details
Definition tag_strings.h:125