mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-28 17:19:34 +08:00
Adding on demand truncation for basic file sinks (#3280)
* Adding support to truncate on demand for basic file sink * Remove unnecessary file close * Adding lock in basic_file_sink truncate()
This commit is contained in:

committed by
GitHub

parent
1e6250e183
commit
65e388e82b
@@ -26,6 +26,12 @@ SPDLOG_INLINE const filename_t &basic_file_sink<Mutex>::filename() const {
|
||||
return file_helper_.filename();
|
||||
}
|
||||
|
||||
template <typename Mutex>
|
||||
SPDLOG_INLINE void basic_file_sink<Mutex>::truncate() {
|
||||
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
|
||||
file_helper_.reopen(true);
|
||||
}
|
||||
|
||||
template <typename Mutex>
|
||||
SPDLOG_INLINE void basic_file_sink<Mutex>::sink_it_(const details::log_msg &msg) {
|
||||
memory_buf_t formatted;
|
||||
|
@@ -23,6 +23,7 @@ public:
|
||||
bool truncate = false,
|
||||
const file_event_handlers &event_handlers = {});
|
||||
const filename_t &filename() const;
|
||||
void truncate();
|
||||
|
||||
protected:
|
||||
void sink_it_(const details::log_msg &msg) override;
|
||||
|
Reference in New Issue
Block a user