From 6be381bf20800f40600fd601d73ec9d1813ac0b5 Mon Sep 17 00:00:00 2001 From: Bailey Chittle Date: Mon, 13 Mar 2023 13:59:39 -0400 Subject: [PATCH] added scrambling --- example/example.cpp | 2 +- include/spdlog/details/log_attr.h | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/example/example.cpp b/example/example.cpp index b9095808..75ce2d3a 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -414,7 +414,7 @@ void attribute_example() { s_logger->push_context(spdlog::attribute_list{{"key\n1", "value\n1"}}); s_logger->info("structured logging: test 1"); - s_logger->push_context(spdlog::attribute_list{{"key\n2", "value\n2"}}); + s_logger->push_context(spdlog::attribute_list{{"key\n2", 1}}); s_logger->info("structured logging: test 2"); s_logger->pop_context(); s_logger->info("structured logging: test 3"); diff --git a/include/spdlog/details/log_attr.h b/include/spdlog/details/log_attr.h index d02df72c..19be5d08 100644 --- a/include/spdlog/details/log_attr.h +++ b/include/spdlog/details/log_attr.h @@ -27,16 +27,18 @@ public: template::value, key_t>::type * = nullptr, typename std::enable_if::value, value_t>::type * = nullptr> attr(key_t const &k, value_t const &v) - : key(std::string(k)) - , value(std::string(v)) - {} + { + scramble(key, k); + scramble(value, v); + } template::value, key_t>::type * = nullptr, typename std::enable_if::value, value_t>::type * = nullptr> attr(key_t const &k, value_t const &v) - : key(std::string(k)) - , value(std::to_string(v)) - {} + { + scramble(key, k); + value = std::to_string(v); + } }; } // namespace details