Agora
1.2.0
Agora project
|
Go to the documentation of this file.
36 SPDLOG_FILENAME_T(
"{}_{:04d}-{:02d}-{:02d}{}"), basename, now_tm.tm_year + 1900, now_tm.tm_mon + 1, now_tm.tm_mday, ext);
51 #ifdef SPDLOG_USE_STD_FORMAT
59 tm_format.push_back(
' ');
61 const size_t MIN_SIZE = 10;
66 size_t count =
strftime(buf.data(), buf.size(), tm_format.c_str(), &now_tm);
70 buf.resize(
count - 1);
73 buf.resize(buf.size() * 2);
80 # if defined(_MSC_VER) && defined(SPDLOG_WCHAR_FILENAMES) // for some reason msvc doesn't allow fmt::runtime(..) with wchar here
90 # pragma GCC diagnostic push
91 # pragma GCC diagnostic ignored "-Wformat-nonliteral"
104 #if defined(__GNUC__)
105 # pragma GCC diagnostic pop
114 template<
typename Mutex,
typename FileNameCalc = daily_filename_calculator>
129 if (rotation_hour < 0 || rotation_hour > 23 || rotation_minute < 0 || rotation_minute > 59)
154 auto time = msg.
time;
184 std::vector<filename_t> filenames;
194 now -= std::chrono::hours(24);
196 for (
auto iter = filenames.rbegin(); iter != filenames.rend(); ++iter)
204 time_t tnow = log_clock::to_time_t(tp);
215 auto rotation_time = log_clock::from_time_t(std::mktime(&date));
216 if (rotation_time >
now)
218 return rotation_time;
220 return {rotation_time + std::chrono::hours(24)};
265 template<
typename Factory = spdlog::synchronous_factory>
267 bool truncate =
false, uint16_t max_files = 0,
const file_event_handlers &event_handlers = {})
269 return Factory::template create<sinks::daily_file_sink_mt>(logger_name,
filename, hour, minute, truncate, max_files, event_handlers);
272 template<
typename Factory = spdlog::synchronous_factory>
274 int minute = 0,
bool truncate =
false, uint16_t max_files = 0,
const file_event_handlers &event_handlers = {})
276 return Factory::template create<sinks::daily_file_format_sink_mt>(
277 logger_name,
filename, hour, minute, truncate, max_files, event_handlers);
280 template<
typename Factory = spdlog::synchronous_factory>
282 bool truncate =
false, uint16_t max_files = 0,
const file_event_handlers &event_handlers = {})
284 return Factory::template create<sinks::daily_file_sink_st>(logger_name,
filename, hour, minute, truncate, max_files, event_handlers);
287 template<
typename Factory = spdlog::synchronous_factory>
289 int minute = 0,
bool truncate =
false, uint16_t max_files = 0,
const file_event_handlers &event_handlers = {})
291 return Factory::template create<sinks::daily_file_format_sink_st>(
292 logger_name,
filename, hour, minute, truncate, max_files, event_handlers);
tm now_tm(log_clock::time_point tp)
Definition: daily_file_sink.h:202
int rotation_h_
Definition: daily_file_sink.h:246
void open(const filename_t &fname, bool truncate=false)
Definition: file_helper-inl.h:32
void flush_() override
Definition: daily_file_sink.h:173
std::basic_string< Char > format(const text_style &ts, const S &format_str, const Args &... args)
Definition: color.h:594
details::file_helper file_helper_
Definition: daily_file_sink.h:249
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
Definition: file_helper.h:16
void pop_front()
Definition: circular_q.h:99
static filename_t calc_filename(const filename_t &filename, const tm &now_tm)
Definition: daily_file_sink.h:31
std::shared_ptr< logger > daily_logger_format_st(const std::string &logger_name, const filename_t &filename, int hour=0, int minute=0, bool truncate=false, uint16_t max_files=0, const file_event_handlers &event_handlers={})
Definition: daily_file_sink.h:288
daily_file_sink(filename_t base_filename, int rotation_hour, int rotation_minute, bool truncate=false, uint16_t max_files=0, const file_event_handlers &event_handlers={})
Definition: daily_file_sink.h:119
SPDLOG_INLINE spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT
Definition: os-inl.h:71
SPDLOG_INLINE int remove_if_exists(const filename_t &filename) SPDLOG_NOEXCEPT
Definition: os-inl.h:172
count
Definition: inspect_agora_results.m:96
void init_filenames_q_()
Definition: daily_file_sink.h:179
filename
Definition: parse_all_dl.m:14
log_clock::time_point rotation_tp_
Definition: daily_file_sink.h:248
filename_t filename()
Definition: daily_file_sink.h:145
std::shared_ptr< logger > daily_logger_mt(const std::string &logger_name, const filename_t &filename, int hour=0, int minute=0, bool truncate=false, uint16_t max_files=0, const file_event_handlers &event_handlers={})
Definition: daily_file_sink.h:266
int rotation_m_
Definition: daily_file_sink.h:247
SPDLOG_INLINE void throw_spdlog_ex(const std::string &msg, int last_errno)
Definition: common-inl.h:72
Definition: base_sink.h:19
const filename_t & filename() const
Definition: file_helper-inl.h:131
uint16_t max_files_
Definition: daily_file_sink.h:251
SPDLOG_INLINE std::string filename_to_str(const filename_t &filename)
Definition: os-inl.h:398
void delete_old_()
Definition: daily_file_sink.h:225
SPDLOG_INLINE std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT
Definition: os-inl.h:84
Definition: daily_file_sink.h:115
details::circular_q< filename_t > filenames_q_
Definition: daily_file_sink.h:252
std::shared_ptr< logger > daily_logger_st(const std::string &logger_name, const filename_t &filename, int hour=0, int minute=0, bool truncate=false, uint16_t max_files=0, const file_event_handlers &event_handlers={})
Definition: daily_file_sink.h:281
void write(const memory_buf_t &buf)
Definition: file_helper-inl.h:112
#define SPDLOG_FILENAME_T(s)
Definition: common.h:123
void flush()
Definition: file_helper-inl.h:85
void sink_it_(const details::log_msg &msg) override
Definition: daily_file_sink.h:152
std::shared_ptr< logger > daily_logger_format_mt(const std::string &logger_name, const filename_t &filename, int hour=0, int minute=0, bool truncate=false, uint16_t max_files=0, const file_event_handlers &event_handlers={})
Definition: daily_file_sink.h:273
#define SPDLOG_FMT_RUNTIME(format_string)
Definition: common.h:54
filename_t base_filename_
Definition: daily_file_sink.h:245
bool truncate_
Definition: daily_file_sink.h:250
std::string filename_t
Definition: common.h:122
Definition: daily_file_sink.h:28
const T & front() const
Definition: circular_q.h:66
log_clock::time_point next_rotation_tp_()
Definition: daily_file_sink.h:208
log_clock::time_point time
Definition: log_msg.h:22
void push_back(T &&item)
Definition: circular_q.h:49
std::string format(const T &value)
Definition: utils.h:15