Udpated README

This commit is contained in:
gabime 2018-08-13 12:33:58 +03:00
parent aefde13858
commit 1d672d39cf

View File

@ -181,7 +181,7 @@ void async_example()
``` ```
--- ---
#### Logger with multi targets - each with different format and log level #### Logger with multi sinks - each with different format and log level
```c++ ```c++
// create logger with 2 targets with different log levels and formats. // create logger with 2 targets with different log levels and formats.
@ -201,6 +201,22 @@ void multi_sink_example()
logger.info("this message should not appear in the console, only in the file"); logger.info("this message should not appear in the console, only in the file");
} }
``` ```
---
#### Async logger with multi sinks
```c++
// create asynchronous logger with 2 sinks.
void multi_sink_example2()
{
spdlog::init_thread_pool(8192, 1);
auto stdout_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt >();
auto rotating_sink = std::make_shared<spdlog::sinks::rotating_file_sink_mt>("mylog.txt", 1024*1024*10, 3);
std::vector<spdlog::sink_ptr> sinks {stdout_sink, rotating_sink};
auto logger = std::make_shared<spdlog::async_logger>("loggername", sinks.begin(), sinks.end(), spdlog::thread_pool(), spdlog::async_overflow_policy::block);
spdlog::register_logger(logger);
}
```
--- ---
#### User defined types #### User defined types
```c++ ```c++