File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 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)
437437 logger->info("Some info message");
438438}
439439```
440+ ---
440441
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+ ```
441456---
442457## Benchmarks
443458
You can’t perform that action at this time.
0 commit comments