diff --git a/include/spdlog/details/log_msg.h b/include/spdlog/details/log_msg.h index 21f8bc6d..6244f3a9 100644 --- a/include/spdlog/details/log_msg.h +++ b/include/spdlog/details/log_msg.h @@ -15,7 +15,6 @@ namespace spdlog { namespace details { struct log_msg { - log_msg() = default; log_msg(const std::string *loggers_name, level::level_enum lvl, string_view_t view) : logger_name(loggers_name) @@ -38,9 +37,9 @@ struct log_msg level::level_enum level{level::off}; log_clock::time_point time; size_t thread_id{0}; - size_t msg_id; + size_t msg_id{0}; - // info about wrapping the formatted text with color (updated by pattern_formatter). + // wrapping the formatted text with color (updated by pattern_formatter). mutable size_t color_range_start{0}; mutable size_t color_range_end{0}; diff --git a/include/spdlog/details/thread_pool.h b/include/spdlog/details/thread_pool.h index de01ad58..ec9d1788 100644 --- a/include/spdlog/details/thread_pool.h +++ b/include/spdlog/details/thread_pool.h @@ -82,12 +82,17 @@ struct async_msg } async_msg(async_logger_ptr &&worker, async_msg_type the_type) - : async_msg(std::move(worker), the_type, details::log_msg()) + : msg_type(the_type) + , level(level::off) + , time() + , thread_id(0) + , msg_id(0) + , worker_ptr(std::move(worker)) { } explicit async_msg(async_msg_type the_type) - : async_msg(nullptr, the_type, details::log_msg()) + : async_msg(nullptr, the_type) { } diff --git a/tests/file_helper.cpp b/tests/file_helper.cpp index bfe7eb9d..ecdc5afe 100644 --- a/tests/file_helper.cpp +++ b/tests/file_helper.cpp @@ -10,7 +10,6 @@ static const std::string target_filename = "logs/file_helper_test.txt"; static void write_with_helper(file_helper &helper, size_t howmany) { - log_msg msg; fmt::memory_buffer formatted; fmt::format_to(formatted, "{}", std::string(howmany, '1')); helper.write(formatted); diff --git a/tests/test_pattern_formatter.cpp b/tests/test_pattern_formatter.cpp index 8b8c9447..7b062a5d 100644 --- a/tests/test_pattern_formatter.cpp +++ b/tests/test_pattern_formatter.cpp @@ -75,7 +75,8 @@ TEST_CASE("color range test1", "[pattern_formatter]") TEST_CASE("color range test2", "[pattern_formatter]") { auto formatter = std::make_shared("%^%$", spdlog::pattern_time_type::local, "\n"); - spdlog::details::log_msg msg; + std::string logger_name = "test"; + spdlog::details::log_msg msg(&logger_name, spdlog::level::info, ""); fmt::memory_buffer formatted; formatter->format(msg, formatted); REQUIRE(msg.color_range_start == 0); @@ -86,7 +87,8 @@ TEST_CASE("color range test2", "[pattern_formatter]") TEST_CASE("color range test3", "[pattern_formatter]") { auto formatter = std::make_shared("%^***%$"); - spdlog::details::log_msg msg; + std::string logger_name = "test"; + spdlog::details::log_msg msg(&logger_name, spdlog::level::info, "ignored"); fmt::memory_buffer formatted; formatter->format(msg, formatted); REQUIRE(msg.color_range_start == 0); @@ -109,7 +111,8 @@ TEST_CASE("color range test4", "[pattern_formatter]") TEST_CASE("color range test5", "[pattern_formatter]") { auto formatter = std::make_shared("**%^"); - spdlog::details::log_msg msg; + std::string logger_name = "test"; + spdlog::details::log_msg msg(&logger_name, spdlog::level::info, "ignored"); fmt::memory_buffer formatted; formatter->format(msg, formatted); REQUIRE(msg.color_range_start == 2); @@ -119,7 +122,8 @@ TEST_CASE("color range test5", "[pattern_formatter]") TEST_CASE("color range test6", "[pattern_formatter]") { auto formatter = std::make_shared("**%$"); - spdlog::details::log_msg msg; + std::string logger_name = "test"; + spdlog::details::log_msg msg(&logger_name, spdlog::level::info, "ignored"); fmt::memory_buffer formatted; formatter->format(msg, formatted); REQUIRE(msg.color_range_start == 0);