Add get_max_size() and set_max_size() methods to rotating_file_sink class.

Signed-off-by: Vitalii Koshura <lestat.de.lionkur@gmail.com>
pull/2281/head
Vitalii Koshura 4 years ago committed by Vitalii Koshura
parent f2461f1430
commit 5e03783d2d
No known key found for this signature in database
GPG Key ID: CE0DB1726070A5A3

@ -35,7 +35,7 @@ SPDLOG_INLINE rotating_file_sink<Mutex>::rotating_file_sink(
{ {
throw_spdlog_ex("rotating sink constructor: max_size arg cannot be zero"); throw_spdlog_ex("rotating sink constructor: max_size arg cannot be zero");
} }
if (max_files > 200000) if (max_files > 200000)
{ {
throw_spdlog_ex("rotating sink constructor: max_files arg cannot exceed 200000"); throw_spdlog_ex("rotating sink constructor: max_files arg cannot exceed 200000");
@ -71,6 +71,24 @@ SPDLOG_INLINE filename_t rotating_file_sink<Mutex>::filename()
return file_helper_.filename(); return file_helper_.filename();
} }
template<typename Mutex>
SPDLOG_INLINE std::size_t rotating_file_sink<Mutex>::get_max_size() const
{
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
return max_size_;
}
template<typename Mutex>
SPDLOG_INLINE void rotating_file_sink<Mutex>::set_max_size(const std::size_t max_size)
{
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
if (max_size == 0)
{
throw_spdlog_ex("rotating sink set_max_size: max_size cannot be zero");
}
max_size_ = max_size;
}
template<typename Mutex> template<typename Mutex>
SPDLOG_INLINE void rotating_file_sink<Mutex>::sink_it_(const details::log_msg &msg) SPDLOG_INLINE void rotating_file_sink<Mutex>::sink_it_(const details::log_msg &msg)
{ {

@ -26,6 +26,8 @@ public:
const file_event_handlers &event_handlers = {}); const file_event_handlers &event_handlers = {});
static filename_t calc_filename(const filename_t &filename, std::size_t index); static filename_t calc_filename(const filename_t &filename, std::size_t index);
filename_t filename(); filename_t filename();
std::size_t get_max_size() const;
void set_max_size(const std::size_t max_size);
protected: protected:
void sink_it_(const details::log_msg &msg) override; void sink_it_(const details::log_msg &msg) override;

Loading…
Cancel
Save