From 58db7e819df1640f2e15032ae4c05a44b45d34a5 Mon Sep 17 00:00:00 2001 From: wangdan Date: Tue, 11 Jul 2023 20:45:26 +0800 Subject: [PATCH] =?UTF-8?q?[SD][SKV-700]=20=E4=BF=AE=E5=A4=8Dskv=202.4.0?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E9=87=8D=E5=A4=8D=E6=89=93=E5=8D=B0=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rdsn/src/utils/simple_logger.cpp | 7 +------ src/rdsn/src/utils/simple_logger.h | 1 - src/rdsn/src/utils/test/logger.cpp | 1 - 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/rdsn/src/utils/simple_logger.cpp b/src/rdsn/src/utils/simple_logger.cpp index c998ba386a..69fcf070f7 100644 --- a/src/rdsn/src/utils/simple_logger.cpp +++ b/src/rdsn/src/utils/simple_logger.cpp @@ -146,7 +146,6 @@ void simple_logger::create_log_file() _file_bytes = 0; uint64_t ts = dsn::utils::get_current_physical_time_ns(); - char time_str[32]; ::dsn::utils::time_ms_to_string_for_log_file_name(ts / 1000000, time_str); @@ -183,6 +182,7 @@ void simple_logger::remove_redundant_files() { std::vector matching_files; dsn::utils::glob(_file_path_pattern, matching_files); + auto max_matches = static_cast(FLAGS_max_number_of_log_files_on_disk); if (matching_files.size() <= max_matches) { return; @@ -204,7 +204,6 @@ void simple_logger::remove_redundant_files() // Use mtime to determine which matching files to delete. This could // potentially be ambiguous, depending on the resolution of last-modified // timestamp in the filesystem, but that is part of the contract. - std::sort(matching_file_mtimes.begin(), matching_file_mtimes.end()); matching_file_mtimes.resize(matching_file_mtimes.size() - max_matches); @@ -251,7 +250,6 @@ void simple_logger::dsn_logv(const char *file, dassert(_log != nullptr, "Log file hasn't been initialized yet"); write_header(log_level); - if (!FLAGS_short_header) { write_log("%s:%d:%s(): ", file, line, function); } @@ -286,13 +284,10 @@ void simple_logger::dsn_log(const char *file, dassert(_log != nullptr, "Log file hasn't been initialized yet"); write_header(log_level); - if (!FLAGS_short_header) { write_log("%s:%d:%s(): ", file, line, function); } write_log("%s\n", str); - - fprintf(_log, "%s\n", str); if (FLAGS_fast_flush || log_level >= LOG_LEVEL_ERROR) { ::fflush(_log); } diff --git a/src/rdsn/src/utils/simple_logger.h b/src/rdsn/src/utils/simple_logger.h index 0e5f66c23a..7cdd5ab02d 100644 --- a/src/rdsn/src/utils/simple_logger.h +++ b/src/rdsn/src/utils/simple_logger.h @@ -90,7 +90,6 @@ class simple_logger : public logging_provider private: void create_log_file(); - void remove_redundant_files(); inline void add_bytes_if_valid(int bytes) diff --git a/src/rdsn/src/utils/test/logger.cpp b/src/rdsn/src/utils/test/logger.cpp index ef77b5e0f4..301364d9fc 100644 --- a/src/rdsn/src/utils/test/logger.cpp +++ b/src/rdsn/src/utils/test/logger.cpp @@ -155,6 +155,5 @@ TEST(tools_common, simple_logger) std::vector file_name_list(files.begin(), files.end()); clear_files(file_name_list); - finish_test_dir(); }