perf: Logger析构时不滚动日志 (#7975)

This commit is contained in:
status102
2024-01-11 21:36:25 +08:00
committed by GitHub
parent 1e36e9ba48
commit db73e2f56e

View File

@@ -476,7 +476,7 @@ namespace asst
LogStream(std::unique_lock<std::mutex>&&, stream_t&&, Args&&...) -> LogStream<stream_t>;
public:
virtual ~Logger() override { flush(); }
virtual ~Logger() override { flush(false); }
// static bool set_directory(const std::filesystem::path& dir)
// {
@@ -578,13 +578,15 @@ namespace asst
<< ... << std::forward<Args>(args));
}
void flush()
void flush(bool rorate_log_file = true)
{
std::unique_lock<std::mutex> m_trace_lock(m_trace_mutex);
if (m_ofs.is_open()) {
m_ofs.close();
}
rotate();
if (rorate_log_file) {
rotate();
}
}
private: