Agora  1.2.0
Agora project
basic_file_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 
10 
11 #include <mutex>
12 #include <string>
13 
14 namespace spdlog {
15 namespace sinks {
16 /*
17  * Trivial file sink with single file as target
18  */
19 template<typename Mutex>
20 class basic_file_sink final : public base_sink<Mutex>
21 {
22 public:
23  explicit basic_file_sink(const filename_t &filename, bool truncate = false, const file_event_handlers &event_handlers = {});
24  const filename_t &filename() const;
25 
26 protected:
27  void sink_it_(const details::log_msg &msg) override;
28  void flush_() override;
29 
30 private:
32 };
33 
36 
37 } // namespace sinks
38 
39 //
40 // factory functions
41 //
42 template<typename Factory = spdlog::synchronous_factory>
43 inline std::shared_ptr<logger> basic_logger_mt(
44  const std::string &logger_name, const filename_t &filename, bool truncate = false, const file_event_handlers &event_handlers = {})
45 {
46  return Factory::template create<sinks::basic_file_sink_mt>(logger_name, filename, truncate, event_handlers);
47 }
48 
49 template<typename Factory = spdlog::synchronous_factory>
50 inline std::shared_ptr<logger> basic_logger_st(
51  const std::string &logger_name, const filename_t &filename, bool truncate = false, const file_event_handlers &event_handlers = {})
52 {
53  return Factory::template create<sinks::basic_file_sink_st>(logger_name, filename, truncate, event_handlers);
54 }
55 
56 } // namespace spdlog
57 
58 #ifdef SPDLOG_HEADER_ONLY
59 # include "basic_file_sink-inl.h"
60 #endif
file_helper.h
spdlog::sinks::basic_file_sink::sink_it_
void sink_it_(const details::log_msg &msg) override
Definition: basic_file_sink-inl.h:30
spdlog::file_event_handlers
Definition: common.h:308
spdlog::basic_logger_st
std::shared_ptr< logger > basic_logger_st(const std::string &logger_name, const filename_t &filename, bool truncate=false, const file_event_handlers &event_handlers={})
Definition: basic_file_sink.h:50
spdlog::sinks::basic_file_sink
Definition: basic_file_sink.h:20
base_sink.h
spdlog::sinks::basic_file_sink::basic_file_sink
basic_file_sink(const filename_t &filename, bool truncate=false, const file_event_handlers &event_handlers={})
Definition: basic_file_sink-inl.h:17
spdlog::details::file_helper
Definition: file_helper.h:16
synchronous_factory.h
filename
filename
Definition: parse_all_dl.m:14
null_mutex.h
spdlog
Definition: async.h:25
spdlog::sinks::base_sink
Definition: base_sink.h:19
spdlog::sinks::basic_file_sink::file_helper_
details::file_helper file_helper_
Definition: basic_file_sink.h:31
spdlog::sinks::basic_file_sink::flush_
void flush_() override
Definition: basic_file_sink-inl.h:38
spdlog::basic_logger_mt
std::shared_ptr< logger > basic_logger_mt(const std::string &logger_name, const filename_t &filename, bool truncate=false, const file_event_handlers &event_handlers={})
Definition: basic_file_sink.h:43
spdlog::sinks::basic_file_sink::filename
const filename_t & filename() const
Definition: basic_file_sink-inl.h:24
spdlog::details::log_msg
Definition: log_msg.h:11
basic_file_sink-inl.h
spdlog::filename_t
std::string filename_t
Definition: common.h:122