|
|
@ -4,8 +4,8 @@
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#include "includes.h"
|
|
|
|
#include "includes.h"
|
|
|
|
#include "spdlog/sinks/daily_file_sink.h"
|
|
|
|
#include "spdlog/sinks/daily_file_sink.h"
|
|
|
|
#include "spdlog/sinks/rotating_file_sink.h"
|
|
|
|
|
|
|
|
#include "spdlog/sinks/hourly_file_sink.h"
|
|
|
|
#include "spdlog/sinks/hourly_file_sink.h"
|
|
|
|
|
|
|
|
#include "spdlog/sinks/rotating_file_sink.h"
|
|
|
|
|
|
|
|
|
|
|
|
using filename_memory_buf_t = spdlog::memory_buf_t;
|
|
|
|
using filename_memory_buf_t = spdlog::memory_buf_t;
|
|
|
|
|
|
|
|
|
|
|
@ -48,8 +48,7 @@ TEST_CASE("daily_logger with custom calculator", "[daily_logger]") {
|
|
|
|
std::tm tm = spdlog::details::os::localtime();
|
|
|
|
std::tm tm = spdlog::details::os::localtime();
|
|
|
|
|
|
|
|
|
|
|
|
auto w = spdlog::fmt_lib::format(SPDLOG_FILENAME_T("{}{:04d}{:02d}{:02d}"), basename.native(), tm.tm_year + 1900,
|
|
|
|
auto w = spdlog::fmt_lib::format(SPDLOG_FILENAME_T("{}{:04d}{:02d}{:02d}"), basename.native(), tm.tm_year + 1900,
|
|
|
|
tm.tm_mon + 1,
|
|
|
|
tm.tm_mon + 1, tm.tm_mday);
|
|
|
|
tm.tm_mday);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto logger = spdlog::create<sink_type>("logger", basename, 0, 0);
|
|
|
|
auto logger = spdlog::create<sink_type>("logger", basename, 0, 0);
|
|
|
|
for (int i = 0; i < 10; ++i) {
|
|
|
|
for (int i = 0; i < 10; ++i) {
|
|
|
@ -87,8 +86,7 @@ TEST_CASE("rotating_file_sink::calc_filename3", "[rotating_file_sink]") {
|
|
|
|
TEST_CASE("daily_file_sink::daily_filename_calculator", "[daily_file_sink]") {
|
|
|
|
TEST_CASE("daily_file_sink::daily_filename_calculator", "[daily_file_sink]") {
|
|
|
|
// daily_YYYY-MM-DD_hh-mm.txt
|
|
|
|
// daily_YYYY-MM-DD_hh-mm.txt
|
|
|
|
auto filename =
|
|
|
|
auto filename =
|
|
|
|
spdlog::sinks::daily_filename_calculator::calc_filename(SPDLOG_FILENAME_T("daily.txt"),
|
|
|
|
spdlog::sinks::daily_filename_calculator::calc_filename(SPDLOG_FILENAME_T("daily.txt"), spdlog::details::os::localtime());
|
|
|
|
spdlog::details::os::localtime());
|
|
|
|
|
|
|
|
// date regex based on https://www.regular-expressions.info/dates.html
|
|
|
|
// date regex based on https://www.regular-expressions.info/dates.html
|
|
|
|
std::basic_regex<spdlog::filename_t::value_type> re(
|
|
|
|
std::basic_regex<spdlog::filename_t::value_type> re(
|
|
|
|
SPDLOG_FILENAME_T(R"(^daily_(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])\.txt$)"));
|
|
|
|
SPDLOG_FILENAME_T(R"(^daily_(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])\.txt$)"));
|
|
|
@ -97,11 +95,10 @@ TEST_CASE("daily_file_sink::daily_filename_calculator", "[daily_file_sink]") {
|
|
|
|
REQUIRE(std::regex_match(filename.native(), match, re));
|
|
|
|
REQUIRE(std::regex_match(filename.native(), match, re));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_CASE("hourly_file_sink::hourly_filename_calculator", "[hrouly_file_sink]") {
|
|
|
|
TEST_CASE("hourly_file_sink::hourly_filename_calculator", "[hrouly_file_sink]") {
|
|
|
|
// daily_YYYY-MM-DD_hh-mm.txt
|
|
|
|
// daily_YYYY-MM-DD_hh-mm.txt
|
|
|
|
auto filename =
|
|
|
|
auto filename = spdlog::sinks::hourly_filename_calculator::calc_filename(SPDLOG_FILENAME_T("hourly.txt"),
|
|
|
|
spdlog::sinks::hourly_filename_calculator::calc_filename(SPDLOG_FILENAME_T("hourly.txt"), spdlog::details::os::localtime());
|
|
|
|
spdlog::details::os::localtime());
|
|
|
|
// date regex based on https://www.regular-expressions.info/dates.html
|
|
|
|
// date regex based on https://www.regular-expressions.info/dates.html
|
|
|
|
std::basic_regex<spdlog::filename_t::value_type> re(
|
|
|
|
std::basic_regex<spdlog::filename_t::value_type> re(
|
|
|
|
SPDLOG_FILENAME_T(R"(^hourly_(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])_\d\d\.txt$)"));
|
|
|
|
SPDLOG_FILENAME_T(R"(^hourly_(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])_\d\d\.txt$)"));
|
|
|
|