Agora
1.2.0
Agora project
|
Go to the documentation of this file.
34 template<async_overflow_policy OverflowPolicy = async_overflow_policy::block>
37 template<
typename Sink,
typename... SinkArgs>
38 static std::shared_ptr<async_logger>
create(std::string logger_name, SinkArgs &&... args)
44 auto &mutex = registry_inst.tp_mutex();
45 std::lock_guard<std::recursive_mutex> tp_lock(mutex);
46 auto tp = registry_inst.get_tp();
50 registry_inst.set_tp(tp);
53 auto sink = std::make_shared<Sink>(std::forward<SinkArgs>(args)...);
54 auto new_logger = std::make_shared<async_logger>(std::move(logger_name), std::move(sink), std::move(tp), OverflowPolicy);
55 registry_inst.initialize_logger(new_logger);
63 template<
typename Sink,
typename... SinkArgs>
64 inline std::shared_ptr<spdlog::logger>
create_async(std::string logger_name, SinkArgs &&... sink_args)
66 return async_factory::create<Sink>(std::move(logger_name), std::forward<SinkArgs>(sink_args)...);
69 template<
typename Sink,
typename... SinkArgs>
70 inline std::shared_ptr<spdlog::logger>
create_async_nb(std::string logger_name, SinkArgs &&... sink_args)
72 return async_factory_nonblock::create<Sink>(std::move(logger_name), std::forward<SinkArgs>(sink_args)...);
79 auto tp = std::make_shared<details::thread_pool>(q_size, thread_count, on_thread_start, on_thread_stop);
91 q_size, thread_count, [] {}, [] {});
95 inline std::shared_ptr<spdlog::details::thread_pool>
thread_pool()
buffer_context< char > format_context
Definition: core.h:1798
Definition: udp_sink.h:26
void multi_sink_example()
Definition: example.cpp:242
auto format_to(OutputIt out, const text_style &ts, const S &format_str, Args &&... args) -> typename std::enable_if< enable, OutputIt >::type
Definition: color.h:628
static const size_t file_size
Definition: bench.cpp:36
SPDLOG_INLINE void set_error_handler(void(*handler)(const std::string &msg))
Definition: spdlog-inl.h:75
static const size_t default_async_q_size
Definition: async.h:28
void bench_single_threaded(int iters)
Definition: bench.cpp:76
void trace_example()
Definition: example.cpp:210
auto printf(const S &fmt, const T &... args) -> int
Definition: printf.h:631
@ trace
Definition: common.h:213
std::shared_ptr< logger > syslog_logger_mt(const std::string &logger_name, const std::string &syslog_ident="", int syslog_option=0, int syslog_facility=LOG_USER, bool enable_formatting=false)
Definition: syslog_sink.h:97
void bench_mt(int howmany, std::shared_ptr< spdlog::logger > log, size_t thread_count)
Definition: bench.cpp:168
void daily_example()
Definition: example.cpp:133
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
void error(format_string_t< Args... > fmt, Args &&... args)
Definition: spdlog.h:167
std::shared_ptr< logger > rotating_logger_mt(const std::string &logger_name, const filename_t &filename, size_t max_file_size, size_t max_files, bool rotate_on_open=false, const file_event_handlers &event_handlers={})
Definition: rotating_file_sink.h:63
@ off
Definition: common.h:219
std::shared_ptr< logger > udp_logger_mt(const std::string &logger_name, sinks::udp_sink_config skin_config)
Definition: udp_sink.h:69
void basic_example()
Definition: example.cpp:119
SPDLOG_INLINE void flush_every(std::chrono::seconds interval)
Definition: spdlog-inl.h:70
@ warn
Definition: common.h:216
SPDLOG_INLINE std::shared_ptr< spdlog::logger > default_logger()
Definition: spdlog-inl.h:110
void bench_disabled_macro(benchmark::State &state, std::shared_ptr< spdlog::logger > logger)
Definition: latency.cpp:52
void critical(format_string_t< Args... > fmt, Args &&... args)
Definition: spdlog.h:173
SPDLOG_INLINE std::shared_ptr< logger > stdout_color_mt(const std::string &logger_name, color_mode mode)
Definition: stdout_color_sinks-inl.h:16
SPDLOG_INLINE void set_level(level::level_enum log_level)
Definition: spdlog-inl.h:60
SPDLOG_INLINE void set_pattern(std::string pattern, pattern_time_type time_type)
Definition: spdlog-inl.h:30
void clear()
Definition: core.h:832
void bench(int howmany, std::shared_ptr< spdlog::logger > log)
Definition: bench.cpp:148
static const size_t rotating_files
Definition: bench.cpp:37
std::function< void(const filename_t &filename, std::FILE *file_stream)> before_close
Definition: common.h:312
int main(int, char *[])
Definition: example.cpp:33
Pilot RX by socket threads(=reference time)
@ info
Definition: common.h:215
SPDLOG_INLINE spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT
Definition: os-inl.h:71
@ debug
Definition: common.h:214
void set_level(level::level_enum log_level)
Definition: logger-inl.h:67
count
Definition: inspect_agora_results.m:96
void bench_threaded_logging(size_t threads, int iters)
Definition: bench.cpp:40
SPDLOG_INLINE void set_automatic_registration(bool automatic_registration)
Definition: spdlog-inl.h:105
void warn(format_string_t< Args... > fmt, Args &&... args)
Definition: spdlog.h:161
int main(int argc, char *argv[])
Definition: latency.cpp:77
void custom_flags_example()
Definition: example.cpp:327
details::dump_info< typename Container::const_iterator > to_hex(const Container &container, size_t size_per_line=32)
Definition: bin_to_hex.h:72
void stdout_logger_example()
Definition: example.cpp:110
Definition: stopwatch.h:28
void bench_c_string(benchmark::State &state, std::shared_ptr< spdlog::logger > logger)
Definition: latency.cpp:19
filename
Definition: parse_all_dl.m:14
std::shared_ptr< logger > null_logger_mt(const std::string &logger_name)
Definition: null_sink.h:29
std::shared_ptr< logger > daily_logger_mt(const std::string &logger_name, const filename_t &filename, int hour=0, int minute=0, bool truncate=false, uint16_t max_files=0, const file_event_handlers &event_handlers={})
Definition: daily_file_sink.h:266
void udp_example()
Definition: example.cpp:233
SPDLOG_INLINE void apply_all(const std::function< void(std::shared_ptr< logger >)> &fun)
Definition: spdlog-inl.h:85
void fputs(const Char *chars, FILE *stream)
Definition: color.h:478
void syslog_example()
Definition: example.cpp:290
#define SPDLOG_LOGGER_TRACE(logger,...)
Definition: spdlog.h:294
void async_example()
Definition: example.cpp:152
#define SPDLOG_TRACE(...)
Definition: spdlog.h:295
#define SPDLOG_LOGGER_DEBUG(logger,...)
Definition: spdlog.h:302
const char * what() const noexcept override
Definition: common-inl.h:67
SPDLOG_INLINE void enable_backtrace(size_t n_messages)
Definition: spdlog-inl.h:35
for i
Definition: generate_data.m:107
std::shared_ptr< logger > rotating_logger_st(const std::string &logger_name, const filename_t &filename, size_t max_file_size, size_t max_files, bool rotate_on_open=false, const file_event_handlers &event_handlers={})
Definition: rotating_file_sink.h:71
int main(int argc, char *argv[])
Definition: bench.cpp:113
Definition: example.cpp:258
#define SPDLOG_DEBUG(...)
Definition: spdlog.h:303
SPDLOG_INLINE void drop(const std::string &name)
Definition: spdlog-inl.h:90
end start
Definition: inspect_agora_results.m:95
void bench_mt(int howmany, std::shared_ptr< spdlog::logger > log, int thread_count)
Definition: async_bench.cpp:162
SPDLOG_INLINE std::shared_ptr< logger > get(const std::string &name)
Definition: spdlog-inl.h:20
void bench_logger(benchmark::State &state, std::shared_ptr< spdlog::logger > logger)
Definition: latency.cpp:33
Definition: thread_pool.h:32
std::unique_ptr< T > make_unique(Args &&... args)
Definition: common.h:334
void vector_example()
Definition: example.cpp:196
void append(const ContiguousRange &range)
Definition: format.h:771
void rotating_example()
Definition: example.cpp:126
void info(format_string_t< Args... > fmt, Args &&... args)
Definition: spdlog.h:155
std::shared_ptr< logger > daily_logger_st(const std::string &logger_name, const filename_t &filename, int hour=0, int minute=0, bool truncate=false, uint16_t max_files=0, const file_event_handlers &event_handlers={})
Definition: daily_file_sink.h:281
null_sink< details::null_mutex > null_sink_mt
Definition: null_sink.h:23
void user_defined_example()
Definition: example.cpp:275
void text(Numeric x, Numeric y, const std::string &s="")
Definition: matplotlibcpp.h:1834
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
void binary_example()
Definition: example.cpp:176
SPDLOG_INLINE void set_default_logger(std::shared_ptr< spdlog::logger > default_logger)
Definition: spdlog-inl.h:120
void info(format_string_t< Args... > fmt, Args &&... args)
Definition: logger.h:156
int count_lines(const char *filename)
Definition: async_bench.cpp:41
void file_events_example()
Definition: example.cpp:337
function[avg_proc_duration, std_proc_duration]
Definition: parse_dl_file.m:1
std::function< void(const filename_t &filename, std::FILE *file_stream)> after_open
Definition: common.h:311
std::function< void(const filename_t &filename)> after_close
Definition: common.h:313
void replace_default_logger_example()
Definition: example.cpp:356
static std::shared_ptr< async_logger > create(std::string logger_name, SinkArgs &&... args)
Definition: async.h:38
int main(int argc, char *argv[])
Definition: async_bench.cpp:72
void bench_logger_fmt_string(benchmark::State &state, std::shared_ptr< spdlog::logger > logger)
Definition: latency.cpp:42
Definition: json.hpp:5213
Definition: bin_to_hex.h:102
null_sink< details::null_mutex > null_sink_st
Definition: null_sink.h:24
std::shared_ptr< spdlog::details::thread_pool > thread_pool()
Definition: async.h:95
SPDLOG_INLINE void shutdown()
Definition: spdlog-inl.h:100
void set_tp(std::shared_ptr< thread_pool > tp)
Definition: registry-inl.h:127
void load_env_levels()
Definition: env.h:28
#define SPDLOG_VER_MAJOR
Definition: version.h:6
std::function< void(const filename_t &filename)> before_open
Definition: common.h:310
std::shared_ptr< spdlog::logger > create_async_nb(std::string logger_name, SinkArgs &&... sink_args)
Definition: async.h:70
SPDLOG_INLINE void dump_backtrace()
Definition: spdlog-inl.h:45
void err_handler_example()
Definition: example.cpp:281
std::shared_ptr< spdlog::logger > create_async(std::string logger_name, SinkArgs &&... sink_args)
Definition: async.h:64
void thread_fun(std::shared_ptr< spdlog::logger > logger, int howmany)
Definition: async_bench.cpp:154
#define SPDLOG_VER_PATCH
Definition: version.h:8
l
Definition: parse_all_dl.m:71
int i
Definition: example.cpp:260
std::shared_ptr< logger > null_logger_st(const std::string &logger_name)
Definition: null_sink.h:37
std::string filename_t
Definition: common.h:122
#define SPDLOG_VER_MINOR
Definition: version.h:7
void verify_file(const char *filename, int expected_count)
Definition: async_bench.cpp:56
void debug(format_string_t< Args... > fmt, Args &&... args)
Definition: spdlog.h:149
void init_thread_pool(size_t q_size, size_t thread_count, std::function< void()> on_thread_start, std::function< void()> on_thread_stop)
Definition: async.h:76
static const int max_threads
Definition: bench.cpp:38
void stopwatch_example()
Definition: example.cpp:225
void load_levels_example()
Definition: example.cpp:140
std::shared_ptr< thread_pool > get_tp()
Definition: registry-inl.h:133
my_type(int i)
Definition: example.cpp:261
void log(source_loc source, level::level_enum lvl, format_string_t< Args... > fmt, Args &&... args)
Definition: spdlog.h:131
std::string format(const T &value)
Definition: utils.h:15
static registry & instance()
Definition: registry-inl.h:291