diff --git a/src/sled/log/log.cc b/src/sled/log/log.cc index 8bf10ca..ab8b868 100644 --- a/src/sled/log/log.cc +++ b/src/sled/log/log.cc @@ -142,14 +142,14 @@ SetLogLevel(LogLevel level) void SetLogFileName(const char *file_name) { + std::ofstream tmp_stream(file_name, std::ios_base::app); if (tmp_stream.is_open()) { Waiter waiter(g_request_id.fetch_add(1), g_current_id); waiter.wait(); g_log_stream.close(); g_log_file_name = file_name; - std::ofstream tmp_stream(file_name, std::ios_base::app); - g_log_stream = tmp_stream; + g_log_stream = std::ofstream(file_name, std::ios_base::app); } else { LOGE("log", "can't open new log file [{}]", file_name); return;