Update README.md

This commit is contained in:
Gabi Melman 2021-11-15 14:48:20 +02:00 committed by GitHub
parent ea92864a4d
commit da621e4402
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -387,12 +387,7 @@ void file_events_example()
handlers.after_open = [](spdlog::filename_t filename, std::FILE *fstream) { fputs("After opening\n", fstream); }; handlers.after_open = [](spdlog::filename_t filename, std::FILE *fstream) { fputs("After opening\n", fstream); };
handlers.before_close = [](spdlog::filename_t filename, std::FILE *fstream) { fputs("Before closing\n", fstream); }; handlers.before_close = [](spdlog::filename_t filename, std::FILE *fstream) { fputs("Before closing\n", fstream); };
handlers.after_close = [](spdlog::filename_t filename) { spdlog::info("After closing {}", filename); }; handlers.after_close = [](spdlog::filename_t filename) { spdlog::info("After closing {}", filename); };
auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>("logs/events-sample.txt", true, handlers); auto my_logger = spdlog::basic_logger_st("some_logger", "logs/events-sample.txt", true, handlers);
spdlog::logger my_logger("some_logger", file_sink);
// or
// auto my_logger = spdlog::basic_logger_st("some_logger", "logs/events-sample.txt", true, handlers);
my_logger.info("Some log line");
} }
``` ```