34 return fmt::format(
SPDLOG_FILENAME_T(
"{}_{:04d}{:02d}{:02d}_{:02d}{}"), basename, now_tm.tm_year + 1900, now_tm.tm_mon + 1,
35 now_tm.tm_mday, now_tm.tm_hour, ext);
44template<
typename Mutex,
typename FileNameCalc = hourly_filename_calculator>
117 for (
auto iter = filenames.
rbegin(); iter != filenames.
rend(); ++iter)
136 if (rotation_time > now)
138 return rotation_time;
155 bool ok = remove_if_exists(old_filename) == 0;
181template<
typename Factory = spdlog::synchronous_factory>
183 const std::string &logger_name,
const filename_t &filename,
bool truncate =
false, uint16_t max_files = 0)
185 return Factory::template create<sinks::hourly_file_sink_mt>(logger_name, filename, truncate, max_files);
188template<
typename Factory = spdlog::synchronous_factory>
190 const std::string &logger_name,
const filename_t &filename,
bool truncate =
false, uint16_t max_files = 0)
192 return Factory::template create<sinks::hourly_file_sink_st>(logger_name, filename, truncate, max_files);
const filename_t & filename() const
void write(const memory_buf_t &buf)
static std::tuple< filename_t, filename_t > split_by_extension(const filename_t &fname)
void open(const filename_t &fname, bool truncate=false)
log_clock::time_point rotation_tp_
tm now_tm(log_clock::time_point tp)
hourly_file_sink(filename_t base_filename, bool truncate=false, uint16_t max_files=0)
details::circular_q< filename_t > filenames_q_
details::file_helper file_helper_
filename_t base_filename_
log_clock::time_point next_rotation_tp_()
void sink_it_(const details::log_msg &msg) override
#define SPDLOG_FILENAME_T(s)
T emplace_back(T... args)
SPDLOG_INLINE std::string filename_to_str(const filename_t &filename)
SPDLOG_INLINE int remove_if_exists(const filename_t &filename) SPDLOG_NOEXCEPT
SPDLOG_INLINE std::tm localtime() SPDLOG_NOEXCEPT
SPDLOG_INLINE bool path_exists(const filename_t &filename) SPDLOG_NOEXCEPT
std::shared_ptr< logger > hourly_logger_st(const std::string &logger_name, const filename_t &filename, bool truncate=false, uint16_t max_files=0)
std::shared_ptr< logger > hourly_logger_mt(const std::string &logger_name, const filename_t &filename, bool truncate=false, uint16_t max_files=0)
fmt::basic_memory_buffer< char, 250 > memory_buf_t
log_clock::time_point time
static filename_t calc_filename(const filename_t &filename, const tm &now_tm)