diff --git a/example/example.cpp b/example/example.cpp index 23afa6d5..5591b3a0 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -404,5 +404,5 @@ void attribute_example() { std::string logfmt_pattern = "time=%Y-%m-%dT%H:%M:%S.%f%z, name=%n, level=%^%l%$, process=%P, thread=%t, message=\"%v\", "; logfmt_logger->set_pattern(logfmt_pattern); - logfmt_logger->log(spdlog::level::info, "logfmt structured logging", {{"key\n1", "value\n1"}, {"key\r\n2", "value\r\n2"}}); + logfmt_logger->log(spdlog::level::info, "logfmt structured logging", spdlog::attribute_list{{"key\n1", "value\n1"}, {"key\r\n2", "value\r\n2"}}); } \ No newline at end of file diff --git a/include/spdlog/details/log_attr.h b/include/spdlog/details/log_attr.h index 09da714d..5a7330bd 100644 --- a/include/spdlog/details/log_attr.h +++ b/include/spdlog/details/log_attr.h @@ -2,7 +2,7 @@ #include #include -#include +#include #include "attr_composer.h" namespace spdlog { @@ -42,4 +42,7 @@ public: }; } // namespace details + +using attribute_list = std::vector; + } // namespace spdlog \ No newline at end of file diff --git a/include/spdlog/details/log_msg.h b/include/spdlog/details/log_msg.h index f4820494..eeddbac5 100644 --- a/include/spdlog/details/log_msg.h +++ b/include/spdlog/details/log_msg.h @@ -29,7 +29,7 @@ struct SPDLOG_API log_msg source_loc source; string_view_t payload; - std::vector attributes; + attribute_list attributes; }; } // namespace details } // namespace spdlog diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h index 74756303..15934bf5 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -85,7 +85,7 @@ public: void swap(spdlog::logger &other) SPDLOG_NOEXCEPT; template - void log(level::level_enum lvl, const T &msg, std::initializer_list attrs) + void log(level::level_enum lvl, const T &msg, attribute_list attrs) { log(source_loc{}, lvl, msg, attrs); } @@ -128,7 +128,7 @@ public: log_it_(log_msg, log_enabled, traceback_enabled); } - void log(source_loc loc, level::level_enum lvl, string_view_t msg, std::initializer_list attrs) + void log(source_loc loc, level::level_enum lvl, string_view_t msg, attribute_list attrs) { bool log_enabled = should_log(lvl); bool traceback_enabled = tracer_.enabled();