Agora
1.2.0
Agora project
|
Go to the documentation of this file.
35 now_tm.tm_mday, now_tm.tm_hour, ext);
44 template<
typename Mutex,
typename FileNameCalc = hourly_filename_calculator>
107 std::vector<filename_t> filenames;
117 now -= std::chrono::hours(1);
119 for (
auto iter = filenames.rbegin(); iter != filenames.rend(); ++iter)
127 time_t tnow = log_clock::to_time_t(tp);
137 auto rotation_time = log_clock::from_time_t(std::mktime(&date));
138 if (rotation_time >
now)
140 return rotation_time;
142 return {rotation_time + std::chrono::hours(1)};
183 template<
typename Factory = spdlog::synchronous_factory>
187 return Factory::template create<sinks::hourly_file_sink_mt>(logger_name,
filename, truncate, max_files, event_handlers);
190 template<
typename Factory = spdlog::synchronous_factory>
194 return Factory::template create<sinks::hourly_file_sink_st>(logger_name,
filename, truncate, max_files, event_handlers);
std::shared_ptr< logger > hourly_logger_st(const std::string &logger_name, const filename_t &filename, bool truncate=false, uint16_t max_files=0, const file_event_handlers &event_handlers={})
Definition: hourly_file_sink.h:191
void init_filenames_q_()
Definition: hourly_file_sink.h:102
void open(const filename_t &fname, bool truncate=false)
Definition: file_helper-inl.h:32
log_clock::time_point next_rotation_tp_()
Definition: hourly_file_sink.h:131
bool truncate_
Definition: hourly_file_sink.h:170
static std::tuple< filename_t, filename_t > split_by_extension(const filename_t &fname)
Definition: file_helper-inl.h:149
bool full() const
Definition: circular_q.h:109
SPDLOG_INLINE bool path_exists(const filename_t &filename) SPDLOG_NOEXCEPT
Definition: os-inl.h:187
filename_t filename()
Definition: hourly_file_sink.h:68
Definition: file_helper.h:16
void pop_front()
Definition: circular_q.h:99
SPDLOG_INLINE spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT
Definition: os-inl.h:71
void flush_() override
Definition: hourly_file_sink.h:96
SPDLOG_INLINE int remove_if_exists(const filename_t &filename) SPDLOG_NOEXCEPT
Definition: os-inl.h:172
Definition: hourly_file_sink.h:27
tm now_tm(log_clock::time_point tp)
Definition: hourly_file_sink.h:125
log_clock::time_point rotation_tp_
Definition: hourly_file_sink.h:168
void delete_old_()
Definition: hourly_file_sink.h:147
filename
Definition: parse_all_dl.m:14
details::circular_q< filename_t > filenames_q_
Definition: hourly_file_sink.h:172
uint16_t max_files_
Definition: hourly_file_sink.h:171
std::shared_ptr< logger > hourly_logger_mt(const std::string &logger_name, const filename_t &filename, bool truncate=false, uint16_t max_files=0, const file_event_handlers &event_handlers={})
Definition: hourly_file_sink.h:184
details::file_helper file_helper_
Definition: hourly_file_sink.h:169
Definition: base_sink.h:19
const filename_t & filename() const
Definition: file_helper-inl.h:131
SPDLOG_INLINE std::string filename_to_str(const filename_t &filename)
Definition: os-inl.h:398
SPDLOG_INLINE std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT
Definition: os-inl.h:84
void sink_it_(const details::log_msg &msg) override
Definition: hourly_file_sink.h:75
hourly_file_sink(filename_t base_filename, bool truncate=false, uint16_t max_files=0, const file_event_handlers &event_handlers={})
Definition: hourly_file_sink.h:49
static filename_t calc_filename(const filename_t &filename, const tm &now_tm)
Definition: hourly_file_sink.h:30
filename_t base_filename_
Definition: hourly_file_sink.h:167
void write(const memory_buf_t &buf)
Definition: file_helper-inl.h:112
#define SPDLOG_THROW(ex)
Definition: common.h:103
#define SPDLOG_FILENAME_T(s)
Definition: common.h:123
void flush()
Definition: file_helper-inl.h:85
std::string filename_t
Definition: common.h:122
const T & front() const
Definition: circular_q.h:66
log_clock::time_point time
Definition: log_msg.h:22
void push_back(T &&item)
Definition: circular_q.h:49
Definition: hourly_file_sink.h:45
std::string format(const T &value)
Definition: utils.h:15