mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-14 01:32:07 +08:00
Merge branch 'v1.x' of https://github.com/gabime/spdlog into v1.x
This commit is contained in:
commit
e86be93b4a
18
README.md
18
README.md
@ -373,6 +373,24 @@ $ export SPDLOG_LEVEL=info,mylogger=trace
|
|||||||
$ ./example
|
$ ./example
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
#### Log file open/close event handlers
|
||||||
|
```c++
|
||||||
|
// You can get subscribe to get callbacks from spdlog before/after log file has been opened or closed.
|
||||||
|
// This is useful for cleanup procedures or for adding someting the start/end of the log files.
|
||||||
|
void file_events_example()
|
||||||
|
{
|
||||||
|
// pass the spdlog::file_event_handlers_t to file sinks for open/close log file notifications
|
||||||
|
spdlog::file_event_handlers_t handlers;
|
||||||
|
handlers.before_open = [](spdlog::filename_t filename) { spdlog::info("Before opening {}", filename); };
|
||||||
|
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.after_close = [](spdlog::filename_t filename) { spdlog::info("After closing {}", filename); };
|
||||||
|
auto my_logger = spdlog::basic_logger_st("some_logger", "logs/events-sample.txt", true, handlers);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
## Benchmarks
|
## Benchmarks
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user