mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 16:35:45 +08:00
Udpated README
This commit is contained in:
parent
1d672d39cf
commit
d6cc5847fa
35
README.md
35
README.md
@ -166,20 +166,7 @@ spdlog::flush_every(std::chrono::seconds(3));
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
|
||||||
#### Asynchronous logging
|
|
||||||
```c++
|
|
||||||
#include "spdlog/async.h"
|
|
||||||
void async_example()
|
|
||||||
{
|
|
||||||
// default thread pool settings can be modified *before* creating the async logger:
|
|
||||||
// spdlog::init_thread_pool(8192, 1); // queue with 8k items and 1 backing thread.
|
|
||||||
auto async_file = spdlog::basic_logger_mt<spdlog::async_factory>("async_file_logger", "logs/async_log.txt");
|
|
||||||
// alternatively:
|
|
||||||
// auto async_file = spdlog::create_async<spdlog::sinks::basic_file_sink_mt>("async_file_logger", "logs/async_log.txt");
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
---
|
---
|
||||||
#### Logger with multi sinks - each with different format and log level
|
#### Logger with multi sinks - each with different format and log level
|
||||||
```c++
|
```c++
|
||||||
@ -203,9 +190,29 @@ void multi_sink_example()
|
|||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
#### Async logger with multi sinks
|
#### Asynchronous logging
|
||||||
|
```c++
|
||||||
|
#include "spdlog/async.h"
|
||||||
|
#include "spdlog/sinks/basic_file_sink.h"
|
||||||
|
void async_example()
|
||||||
|
{
|
||||||
|
// default thread pool settings can be modified *before* creating the async logger:
|
||||||
|
// spdlog::init_thread_pool(8192, 1); // queue with 8k items and 1 backing thread.
|
||||||
|
auto async_file = spdlog::basic_logger_mt<spdlog::async_factory>("async_file_logger", "logs/async_log.txt");
|
||||||
|
// alternatively:
|
||||||
|
// auto async_file = spdlog::create_async<spdlog::sinks::basic_file_sink_mt>("async_file_logger", "logs/async_log.txt");
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
#### Asynchronous logger with multi sinks
|
||||||
```c++
|
```c++
|
||||||
// create asynchronous logger with 2 sinks.
|
// create asynchronous logger with 2 sinks.
|
||||||
|
|
||||||
|
#include "spdlog/sinks/stdout_color_sinks.h"
|
||||||
|
#include "spdlog/sinks/rotating_file_sink.h"
|
||||||
|
|
||||||
void multi_sink_example2()
|
void multi_sink_example2()
|
||||||
{
|
{
|
||||||
spdlog::init_thread_pool(8192, 1);
|
spdlog::init_thread_pool(8192, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user