Fix example

This commit is contained in:
gabime 2024-12-05 17:49:09 +02:00
parent 24ca20c3c7
commit 7a7b9d8f91

View File

@ -299,16 +299,16 @@ void custom_flags_example() {
void file_events_example() { void file_events_example() {
// pass the spdlog::file_event_handlers to file sinks for open/close log file notifications // pass the spdlog::file_event_handlers to file sinks for open/close log file notifications
spdlog::file_event_handlers handlers; spdlog::file_event_handlers handlers;
handlers.before_open = [](spdlog::filename_t filename) { spdlog::info("Before opening logfile"); }; handlers.before_open = [](spdlog::filename_t) { spdlog::info("Before opening logfile"); };
handlers.after_open = [](spdlog::filename_t filename, std::FILE *fstream) { handlers.after_open = [](spdlog::filename_t, std::FILE *fstream) {
spdlog::info("After opening logfile"); spdlog::info("After opening logfile");
fputs("After opening\n", fstream); fputs("After opening\n", fstream);
}; };
handlers.before_close = [](spdlog::filename_t filename, std::FILE *fstream) { handlers.before_close = [](spdlog::filename_t, std::FILE *fstream) {
spdlog::info("Before closing logfile"); spdlog::info("Before closing logfile");
fputs("Before closing\n", fstream); fputs("Before closing\n", fstream);
}; };
handlers.after_close = [](spdlog::filename_t filename) { spdlog::info("After closing logfile"); }; handlers.after_close = [](spdlog::filename_t) { spdlog::info("After closing logfile"); };
auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>("logs/events-sample.txt", true, handlers); auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>("logs/events-sample.txt", true, handlers);
spdlog::logger my_logger("some_logger", file_sink); spdlog::logger my_logger("some_logger", file_sink);
my_logger.info("Some log line"); my_logger.info("Some log line");