Updated example

This commit is contained in:
gabime 2024-12-06 11:22:09 +02:00
parent 71a3caa018
commit a45d0f0a45

View File

@ -272,19 +272,19 @@ void custom_flags_example() {
void file_events_example() {
// pass the spdlog::file_event_handlers to file sinks for open/close log file notifications
spdlog::file_event_handlers handlers;
handlers.before_open = [](spdlog::filename_t) { spdlog::info("Before opening logfile"); };
handlers.before_open = [](spdlog::filename_t) { spdlog::trace("Before opening logfile"); };
handlers.after_open = [](spdlog::filename_t, std::FILE *fstream) {
spdlog::info("After opening logfile");
spdlog::trace("After opening logfile");
fputs("After opening\n", fstream);
};
handlers.before_close = [](spdlog::filename_t, std::FILE *fstream) {
spdlog::info("Before closing logfile");
spdlog::trace("Before closing logfile");
fputs("Before closing\n", fstream);
};
handlers.after_close = [](spdlog::filename_t) { spdlog::info("After closing logfile"); };
handlers.after_close = [](spdlog::filename_t) { spdlog::trace("After closing logfile"); };
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);
my_logger.info("Some log line");
my_logger.trace("Some log line");
}
void replace_global_logger_example() {