Agora  1.2.0
Agora project
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>
13 #include <spdlog/details/log_msg.h>
14 #include <spdlog/sinks/sink.h>
15 
16 namespace spdlog {
17 namespace sinks {
18 template<typename Mutex>
19 class SPDLOG_API base_sink : public sink
20 {
21 public:
22  base_sink();
23  explicit base_sink(std::unique_ptr<spdlog::formatter> formatter);
24  ~base_sink() override = default;
25 
26  base_sink(const base_sink &) = delete;
27  base_sink(base_sink &&) = delete;
28 
29  base_sink &operator=(const base_sink &) = delete;
30  base_sink &operator=(base_sink &&) = delete;
31 
32  void log(const details::log_msg &msg) final;
33  void flush() final;
34  void set_pattern(const std::string &pattern) final;
35  void set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) final;
36 
37 protected:
38  // sink formatter
39  std::unique_ptr<spdlog::formatter> formatter_;
40  Mutex mutex_;
41 
42  virtual void sink_it_(const details::log_msg &msg) = 0;
43  virtual void flush_() = 0;
44  virtual void set_pattern_(const std::string &pattern);
45  virtual void set_formatter_(std::unique_ptr<spdlog::formatter> sink_formatter);
46 };
47 } // namespace sinks
48 } // namespace spdlog
49 
50 #ifdef SPDLOG_HEADER_ONLY
51 # include "base_sink-inl.h"
52 #endif
spdlog::formatter
Definition: formatter.h:11
spdlog::sinks::sink
Definition: sink.h:12
base_sink-inl.h
spdlog::sinks::base_sink::formatter_
std::unique_ptr< spdlog::formatter > formatter_
Definition: base_sink.h:39
spdlog::set_pattern
SPDLOG_INLINE void set_pattern(std::string pattern, pattern_time_type time_type)
Definition: spdlog-inl.h:30
spdlog
Definition: async.h:25
spdlog::sinks::base_sink
Definition: base_sink.h:19
common.h
spdlog::set_formatter
SPDLOG_INLINE void set_formatter(std::unique_ptr< spdlog::formatter > formatter)
Definition: spdlog-inl.h:25
spdlog::details::log_msg
Definition: log_msg.h:11
sink.h
SPDLOG_API
#define SPDLOG_API
Definition: common.h:40
log_msg.h
spdlog::log
void log(source_loc source, level::level_enum lvl, format_string_t< Args... > fmt, Args &&... args)
Definition: spdlog.h:131
spdlog::sinks::base_sink::mutex_
Mutex mutex_
Definition: base_sink.h:40