auto create log dir

This commit is contained in:
gabime
2019-10-20 17:40:56 +03:00
parent 4858d7e454
commit 9b7812a0f2
18 changed files with 141 additions and 64 deletions

View File

@@ -10,7 +10,7 @@ TEST_CASE("daily_logger with dateonly calculator", "[daily_logger]")
prepare_logdir();
// calculate filename (time based)
std::string basename = "logs/daily_dateonly";
std::string basename = "test_logs/daily_dateonly";
std::tm tm = spdlog::details::os::localtime();
spdlog::memory_buf_t w;
fmt::format_to(w, "{}_{:04d}-{:02d}-{:02d}", basename, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
@@ -44,7 +44,7 @@ TEST_CASE("daily_logger with custom calculator", "[daily_logger]")
prepare_logdir();
// calculate filename (time based)
std::string basename = "logs/daily_dateonly";
std::string basename = "test_logs/daily_dateonly";
std::tm tm = spdlog::details::os::localtime();
spdlog::memory_buf_t w;
fmt::format_to(w, "{}{:04d}{:02d}{:02d}", basename, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
@@ -119,7 +119,7 @@ static void test_rotate(int days_to_run, uint16_t max_days, uint16_t expected_n_
prepare_logdir();
std::string basename = "logs/daily_rotate.txt";
std::string basename = "test_logs/daily_rotate.txt";
daily_file_sink_st sink{basename, 2, 30, true, max_days};
// simulate messages with 24 intervals
@@ -130,7 +130,7 @@ static void test_rotate(int days_to_run, uint16_t max_days, uint16_t expected_n_
sink.log(create_msg(offset));
}
REQUIRE(count_files("logs") == static_cast<size_t>(expected_n_files));
REQUIRE(count_files("test_logs") == static_cast<size_t>(expected_n_files));
}
TEST_CASE("daily_logger rotate", "[daily_file_sink]")