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:
allen_qfl
2024-09-13 03:27:25 +08:00
committed by GitHub
parent 2169a6f6ae
commit 362214a349
5 changed files with 34 additions and 3 deletions

View File

@@ -26,7 +26,11 @@
#include "spdlog/spdlog.h"
#include "spdlog/async.h"
#include "spdlog/details/fmt_helper.h"
#include "spdlog/mdc.h"
#ifndef SPDLOG_NO_TLS
#include "spdlog/mdc.h"
#endif
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/daily_file_sink.h"
#include "spdlog/sinks/null_sink.h"

View File

@@ -501,6 +501,7 @@ TEST_CASE("override need_localtime", "[pattern_formatter]") {
}
}
#ifndef SPDLOG_NO_TLS
TEST_CASE("mdc formatter test-1", "[pattern_formatter]") {
spdlog::mdc::put("mdc_key_1", "mdc_value_1");
spdlog::mdc::put("mdc_key_2", "mdc_value_2");
@@ -628,3 +629,4 @@ TEST_CASE("mdc empty", "[pattern_formatter]") {
SECTION("Tear down") { spdlog::mdc::clear(); }
}
#endif