File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -437,7 +437,22 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
437
437
logger->info("Some info message");
438
438
}
439
439
```
440
+ ---
440
441
442
+ #### Mapped Diagnostic Context
443
+ ```c++
444
+ // Mapped Diagnostic Context (MDC) is a map that stores key-value pairs (string values) in thread local storage.
445
+ // Each thread maintains its own MDC, which loggers use to append diagnostic information to log outputs.
446
+ // Note: it is not supported in asynchronous mode due to its reliance on thread-local storage.
447
+ #include "spdlog/mdc.h"
448
+ void mdc_example()
449
+ {
450
+ spdlog::mdc::put("key1", "value1");
451
+ spdlog::mdc::put("key2", "value2");
452
+ // if not using the default format, use the %& formatter to print mdc data
453
+ // spdlog::set_pattern("[%H:%M:%S %z] [%^%L%$] [%&] %v");
454
+ }
455
+ ```
441
456
---
442
457
## Benchmarks
443
458
You can’t perform that action at this time.
0 commit comments