30 template<
typename Mutex>
35 : base_filename_(
std::move(base_filename))
37 , max_files_(max_files)
40 current_size_ = file_helper_.
size();
41 if (rotate_on_open && current_size_ > 0)
75 current_size_ += formatted.
size();
76 if (current_size_ > max_size_)
79 current_size_ = formatted.
size();
81 file_helper_.
write(formatted);
99 for (
auto i = max_files_; i > 0; --i)
108 if (!rename_file(src, target))
114 if (!rename_file(src, target))
116 file_helper_.
reopen(
true);
123 file_helper_.
reopen(
true);
136 std::size_t max_size_;
137 std::size_t max_files_;
138 std::size_t current_size_;
151 template<
typename Factory = default_factory>
153 const std::string &logger_name,
const filename_t &
filename,
size_t max_file_size,
size_t max_files,
bool rotate_on_open=
false)
155 return Factory::template create<sinks::rotating_file_sink_mt>(logger_name,
filename, max_file_size, max_files, rotate_on_open);
158 template<
typename Factory = default_factory>
160 const std::string &logger_name,
const filename_t &
filename,
size_t max_file_size,
size_t max_files,
bool rotate_on_open =
false)
162 return Factory::template create<sinks::rotating_file_sink_st>(logger_name,
filename, max_file_size, max_files, rotate_on_open);
std::shared_ptr< logger > rotating_logger_mt(const std::string &logger_name, const filename_t &filename, size_t max_file_size, size_t max_files, bool rotate_on_open=false)
void sleep_for_millis(int milliseconds) noexcept
void open(const filename_t &fname, bool truncate=false)
std::shared_ptr< logger > rotating_logger_st(const std::string &logger_name, const filename_t &filename, size_t max_file_size, size_t max_files, bool rotate_on_open=false)
std::unique_ptr< spdlog::formatter > formatter_
static filename_t calc_filename(const filename_t &filename, std::size_t index)
void sink_it_(const details::log_msg &msg) override
void reopen(bool truncate)
const filename_t & filename() const
static std::tuple< filename_t, filename_t > split_by_extension(const spdlog::filename_t &fname)
basic_memory_buffer< char > memory_buffer
int remove(const filename_t &filename) noexcept
void write(const fmt::memory_buffer &buf)
const filename_t & filename() const
int rename(const filename_t &filename1, const filename_t &filename2) noexcept
static bool file_exists(const filename_t &fname)
#define SPDLOG_FILENAME_T(s)
std::enable_if< is_contiguous< Container >::value &&internal::is_string< S >::value, std::back_insert_iterator< Container > >::type format_to(std::back_insert_iterator< Container > out, const S &format_str, const Args &...args)
std::string to_string(const T &value)
rotating_file_sink(filename_t base_filename, std::size_t max_size, std::size_t max_files, bool rotate_on_open=false)
std::string filename_to_str(const filename_t &filename)