Agora  1.2.0
Agora project
stdout_sinks.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 
8 #include <spdlog/sinks/sink.h>
9 #include <cstdio>
10 
11 #ifdef _WIN32
13 #endif
14 
15 namespace spdlog {
16 
17 namespace sinks {
18 
19 template<typename ConsoleMutex>
20 class stdout_sink_base : public sink
21 {
22 public:
23  using mutex_t = typename ConsoleMutex::mutex_t;
24  explicit stdout_sink_base(FILE *file);
25  ~stdout_sink_base() override = default;
26 
27  stdout_sink_base(const stdout_sink_base &other) = delete;
28  stdout_sink_base(stdout_sink_base &&other) = delete;
29 
30  stdout_sink_base &operator=(const stdout_sink_base &other) = delete;
31  stdout_sink_base &operator=(stdout_sink_base &&other) = delete;
32 
33  void log(const details::log_msg &msg) override;
34  void flush() override;
35  void set_pattern(const std::string &pattern) override;
36 
37  void set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) override;
38 
39 protected:
41  FILE *file_;
42  std::unique_ptr<spdlog::formatter> formatter_;
43 #ifdef _WIN32
44  HANDLE handle_;
45 #endif // WIN32
46 };
47 
48 template<typename ConsoleMutex>
49 class stdout_sink : public stdout_sink_base<ConsoleMutex>
50 {
51 public:
52  stdout_sink();
53 };
54 
55 template<typename ConsoleMutex>
56 class stderr_sink : public stdout_sink_base<ConsoleMutex>
57 {
58 public:
59  stderr_sink();
60 };
61 
64 
67 
68 } // namespace sinks
69 
70 // factory methods
71 template<typename Factory = spdlog::synchronous_factory>
72 std::shared_ptr<logger> stdout_logger_mt(const std::string &logger_name);
73 
74 template<typename Factory = spdlog::synchronous_factory>
75 std::shared_ptr<logger> stdout_logger_st(const std::string &logger_name);
76 
77 template<typename Factory = spdlog::synchronous_factory>
78 std::shared_ptr<logger> stderr_logger_mt(const std::string &logger_name);
79 
80 template<typename Factory = spdlog::synchronous_factory>
81 std::shared_ptr<logger> stderr_logger_st(const std::string &logger_name);
82 
83 } // namespace spdlog
84 
85 #ifdef SPDLOG_HEADER_ONLY
86 # include "stdout_sinks-inl.h"
87 #endif
spdlog::sinks::sink
Definition: sink.h:12
spdlog::sinks::stdout_sink_base::operator=
stdout_sink_base & operator=(const stdout_sink_base &other)=delete
windows_include.h
spdlog::stdout_logger_mt
SPDLOG_INLINE std::shared_ptr< logger > stdout_logger_mt(const std::string &logger_name)
Definition: stdout_sinks-inl.h:117
spdlog::stderr_logger_mt
SPDLOG_INLINE std::shared_ptr< logger > stderr_logger_mt(const std::string &logger_name)
Definition: stdout_sinks-inl.h:129
spdlog::sinks::stdout_sink::stdout_sink
stdout_sink()
Definition: stdout_sinks-inl.h:103
spdlog::stderr_logger_st
SPDLOG_INLINE std::shared_ptr< logger > stderr_logger_st(const std::string &logger_name)
Definition: stdout_sinks-inl.h:135
synchronous_factory.h
spdlog::sinks::stdout_sink_base::~stdout_sink_base
~stdout_sink_base() override=default
spdlog::sinks::stdout_sink_base::stdout_sink_base
stdout_sink_base(FILE *file)
Definition: stdout_sinks-inl.h:32
stdout_sinks-inl.h
spdlog::sinks::stdout_sink_base
Definition: stdout_sinks.h:20
spdlog
Definition: async.h:25
spdlog::sinks::stdout_sink_base::mutex_t
typename ConsoleMutex::mutex_t mutex_t
Definition: stdout_sinks.h:23
spdlog::sinks::stdout_sink
Definition: stdout_sinks.h:49
spdlog::sinks::stdout_sink_base::mutex_
mutex_t & mutex_
Definition: stdout_sinks.h:40
spdlog::sinks::stdout_sink_base::set_pattern
void set_pattern(const std::string &pattern) override
Definition: stdout_sinks-inl.h:88
spdlog::sinks::stderr_sink
Definition: stdout_sinks.h:56
spdlog::details::log_msg
Definition: log_msg.h:11
sink.h
spdlog::stdout_logger_st
SPDLOG_INLINE std::shared_ptr< logger > stdout_logger_st(const std::string &logger_name)
Definition: stdout_sinks-inl.h:123
spdlog::sinks::stdout_sink_base::set_formatter
void set_formatter(std::unique_ptr< spdlog::formatter > sink_formatter) override
Definition: stdout_sinks-inl.h:95
spdlog::sinks::stdout_sink_base::log
void log(const details::log_msg &msg) override
Definition: stdout_sinks-inl.h:53
spdlog::sinks::stdout_sink_base::file_
FILE * file_
Definition: stdout_sinks.h:41
spdlog::sinks::stderr_sink::stderr_sink
stderr_sink()
Definition: stdout_sinks-inl.h:109
console_globals.h
spdlog::sinks::stdout_sink_base::flush
void flush() override
Definition: stdout_sinks-inl.h:81
spdlog::sinks::stdout_sink_base::formatter_
std::unique_ptr< spdlog::formatter > formatter_
Definition: stdout_sinks.h:42