mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-13 09:20:25 +08:00
Fix example
This commit is contained in:
parent
24ca20c3c7
commit
7a7b9d8f91
@ -299,16 +299,16 @@ 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 filename) { spdlog::info("Before opening logfile"); };
|
||||
handlers.after_open = [](spdlog::filename_t filename, std::FILE *fstream) {
|
||||
handlers.before_open = [](spdlog::filename_t) { spdlog::info("Before opening logfile"); };
|
||||
handlers.after_open = [](spdlog::filename_t, std::FILE *fstream) {
|
||||
spdlog::info("After opening logfile");
|
||||
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");
|
||||
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);
|
||||
spdlog::logger my_logger("some_logger", file_sink);
|
||||
my_logger.info("Some log line");
|
||||
|
Loading…
Reference in New Issue
Block a user