8TEST_CASE(
"daily_logger with dateonly calculator",
"[daily_logger]")
21 auto logger = spdlog::create<sink_type>(
"logger", basename, 0, 0);
22 for (
int i = 0; i < 10; ++i)
25 logger->info(
"Test message {}", i);
29#ifdef SPDLOG_WCHAR_FILENAMES
31 spdlog::details::os::wstr_to_utf8buf(fmt::to_string(w), buf);
32 auto filename = fmt::to_string(buf);
34 auto filename = fmt::to_string(w);
46 return fmt::to_string(w);
50TEST_CASE(
"daily_logger with custom calculator",
"[daily_logger]")
63 auto logger = spdlog::create<sink_type>(
"logger", basename, 0, 0);
64 for (
int i = 0; i < 10; ++i)
66 logger->info(
"Test message {}", i);
71#ifdef SPDLOG_WCHAR_FILENAMES
73 spdlog::details::os::wstr_to_utf8buf(fmt::to_string(w), buf);
74 auto filename = fmt::to_string(buf);
76 auto filename = fmt::to_string(w);
85TEST_CASE(
"rotating_file_sink::calc_filename1",
"[rotating_file_sink]]")
91TEST_CASE(
"rotating_file_sink::calc_filename2",
"[rotating_file_sink]]")
97TEST_CASE(
"rotating_file_sink::calc_filename3",
"[rotating_file_sink]]")
104#if defined(_MSC_VER) || !(__GNUC__ <= 4 && __GNUC_MINOR__ < 9)
108TEST_CASE(
"daily_file_sink::daily_filename_calculator",
"[daily_file_sink]]")
115 SPDLOG_FILENAME_T(R
"(^daily_(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])\.txt$)"));
126 msg.
time = log_clock::now() + offset;
130static void test_rotate(
int days_to_run, uint16_t max_days, uint16_t expected_n_files)
139 daily_file_sink_st sink{basename, 2, 30,
true, max_days};
143 for (
int i = 0; i < days_to_run; i++)
T back_inserter(T... args)
static filename_t calc_filename(const filename_t &filename, std::size_t index)
#define SPDLOG_FILENAME_T(s)
SPDLOG_INLINE std::tm localtime() SPDLOG_NOEXCEPT
fmt::basic_memory_buffer< char, 250 > memory_buf_t
static spdlog::filename_t calc_filename(const spdlog::filename_t &basename, const tm &now_tm)
log_clock::time_point time
static filename_t calc_filename(const filename_t &filename, const tm &now_tm)
static void test_rotate(int days_to_run, uint16_t max_days, uint16_t expected_n_files)
static spdlog::details::log_msg create_msg(std::chrono::seconds offset)
fmt::basic_memory_buffer< spdlog::filename_t::value_type, 250 > filename_memory_buf_t
void require_message_count(const std::string &filename, const std::size_t messages)
std::size_t count_files(const std::string &folder)