mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-28 17:19:34 +08:00
fix/issue-3101: fix the issue where mdc ignores SPDLOG_NO_TLS (#3184)
Co-authored-by: dyf <yufeng.duan@senscape.com.cn>
This commit is contained in:
@@ -382,7 +382,9 @@ void replace_default_logger_example() {
|
||||
// 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"
|
||||
|
||||
#ifndef SPDLOG_NO_TLS
|
||||
#include "spdlog/mdc.h"
|
||||
void mdc_example()
|
||||
{
|
||||
spdlog::mdc::put("key1", "value1");
|
||||
@@ -391,3 +393,8 @@ void mdc_example()
|
||||
spdlog::set_pattern("[%H:%M:%S %z] [%^%L%$] [%&] %v");
|
||||
spdlog::info("Some log message with context");
|
||||
}
|
||||
#else
|
||||
void mdc_example() {
|
||||
// if TLS feature is disabled
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user