Skip to content

Commit

Permalink
[SD][SKV-700] 修复skv 2.4.0日志重复打印的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
wangdan committed Jul 11, 2023
1 parent e70fd5d commit 58db7e8
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 8 deletions.
7 changes: 1 addition & 6 deletions src/rdsn/src/utils/simple_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -183,6 +182,7 @@ void simple_logger::remove_redundant_files()
{
std::vector<std::string> matching_files;
dsn::utils::glob(_file_path_pattern, matching_files);

auto max_matches = static_cast<size_t>(FLAGS_max_number_of_log_files_on_disk);
if (matching_files.size() <= max_matches) {
return;
Expand All @@ -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);

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion src/rdsn/src/utils/simple_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/rdsn/src/utils/test/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,5 @@ TEST(tools_common, simple_logger)

std::vector<std::string> file_name_list(files.begin(), files.end());
clear_files(file_name_list);

finish_test_dir();
}

0 comments on commit 58db7e8

Please sign in to comment.