diff --git a/include/spdlog/sinks/daily_file_sink.h b/include/spdlog/sinks/daily_file_sink.h index 9fae2c30..ce140415 100644 --- a/include/spdlog/sinks/daily_file_sink.h +++ b/include/spdlog/sinks/daily_file_sink.h @@ -70,6 +70,12 @@ public: } } + filename_t filename() + { + std::lock_guard lock(base_sink::mutex_); + return file_helper_.filename(); + } + protected: void sink_it_(const details::log_msg &msg) override { diff --git a/include/spdlog/sinks/rotating_file_sink-inl.h b/include/spdlog/sinks/rotating_file_sink-inl.h index 3add7854..d715ebf3 100644 --- a/include/spdlog/sinks/rotating_file_sink-inl.h +++ b/include/spdlog/sinks/rotating_file_sink-inl.h @@ -53,6 +53,13 @@ SPDLOG_INLINE filename_t rotating_file_sink::calc_filename(const filename return fmt::format(SPDLOG_FILENAME_T("{}.{}{}"), basename, index, ext); } +template +SPDLOG_INLINE filename_t rotating_file_sink::filename() +{ + std::lock_guard lock(base_sink::mutex_); + return file_helper_.filename(); +} + template SPDLOG_INLINE void rotating_file_sink::sink_it_(const details::log_msg &msg) { diff --git a/include/spdlog/sinks/rotating_file_sink.h b/include/spdlog/sinks/rotating_file_sink.h index 25a1d495..e1e85a7d 100644 --- a/include/spdlog/sinks/rotating_file_sink.h +++ b/include/spdlog/sinks/rotating_file_sink.h @@ -24,6 +24,7 @@ class rotating_file_sink final : public base_sink public: rotating_file_sink(filename_t base_filename, std::size_t max_size, std::size_t max_files, bool rotate_on_open = false); static filename_t calc_filename(const filename_t &filename, std::size_t index); + filename_t filename(); protected: void sink_it_(const details::log_msg &msg) override;