mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 16:35:45 +08:00
Added mdc example to readme
This commit is contained in:
parent
2d4acf8cc3
commit
27cb4c7670
15
README.md
15
README.md
@ -437,7 +437,22 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
|||||||
logger->info("Some info message");
|
logger->info("Some info message");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
---
|
||||||
|
|
||||||
|
#### Mapped Diagnostic Context
|
||||||
|
```c++
|
||||||
|
// Mapped Diagnostic Context (MDC) is a map that stores key-value pairs (string values) in thread local storage.
|
||||||
|
// Each thread maintains its own MDC, which loggers use to append diagnostic information to log outputs.
|
||||||
|
// Note: it is not supported in asynchronous mode due to its reliance on thread-local storage.
|
||||||
|
#include "spdlog/mdc.h"
|
||||||
|
void mdc_example()
|
||||||
|
{
|
||||||
|
spdlog::mdc::put("key1", "value1");
|
||||||
|
spdlog::mdc::put("key2", "value2");
|
||||||
|
// if not using the default format, use the %& formatter to print mdc data
|
||||||
|
// spdlog::set_pattern("[%H:%M:%S %z] [%^%L%$] [%&] %v");
|
||||||
|
}
|
||||||
|
```
|
||||||
---
|
---
|
||||||
## Benchmarks
|
## Benchmarks
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user