diff --git a/CMakeLists.txt b/CMakeLists.txt index f9f90d34..d4c0584a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.3) # project variables project(spdlog_setup VERSION 0.3.0 LANGUAGES CXX) -set(SPDLOG_MIN_VERSION "0.14.0") +set(SPDLOG_MIN_VERSION "1.0.0") # general fixed compiler settings if(${MSVC}) diff --git a/include/spdlog_setup/details/conf_impl.h b/include/spdlog_setup/details/conf_impl.h index 7ab13be1..ce3daa93 100644 --- a/include/spdlog_setup/details/conf_impl.h +++ b/include/spdlog_setup/details/conf_impl.h @@ -132,6 +132,7 @@ static constexpr auto MAX_FILES = "max_files"; static constexpr auto MAX_SIZE = "max_size"; static constexpr auto NAME = "name"; static constexpr auto PATTERN = "pattern"; +static constexpr auto ROTATE_ON_OPEN = "rotate_on_open"; static constexpr auto ROTATION_HOUR = "rotation_hour"; static constexpr auto ROTATION_MINUTE = "rotation_minute"; static constexpr auto SINKS = "sinks"; @@ -697,6 +698,7 @@ auto rotating_file_sink_from_table( using names::BASE_FILENAME; using names::MAX_FILES; using names::MAX_SIZE; + using names::ROTATE_ON_OPEN; // fmt using fmt::format; @@ -731,8 +733,13 @@ auto rotating_file_sink_from_table( "Missing '{}' field of u64 value for rotating_file_sink", MAX_FILES)); + const auto rotate_on_open = value_from_table_or( + sink_table, + ROTATE_ON_OPEN, + false); + return make_shared( - base_filename, max_filesize, max_files); + base_filename, max_filesize, max_files, rotate_on_open); } template @@ -1054,6 +1061,11 @@ inline void setup_loggers_impl( auto global_pattern_opt = value_from_table_opt(config, GLOBAL_PATTERN); + if (global_pattern_opt) + { + spdlog::set_pattern(*global_pattern_opt); + } + for (const auto &logger_table : *loggers) { const auto name = value_from_table( logger_table,