Skip to content

Commit

Permalink
fixed-islogfromcurrentproject func
Browse files Browse the repository at this point in the history
  • Loading branch information
Mivekk committed Jan 16, 2024
1 parent 489d35e commit 4e016e5
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1416,8 +1416,30 @@ bool LogCleaner::IsLogFromCurrentProject(
}
}

// As we want to delete old logs despite their severity,
// we need to replace <severity> in cleaned_base_file and find matching one.
const string::size_type dot_pos =
cleaned_base_filename.find_last_of('.', cleaned_base_filename.size() - 1);

const string new_base_filename = cleaned_base_filename.substr(0, dot_pos);

// Loop through severity names and check whether
// filepath contains cleaned_base_filename_with_severity
bool found_file = false;
for (const auto& severity : LogSeverityNames) {
string cleaned_base_filename_with_severity = new_base_filename + severity;

if (filepath.find(cleaned_base_filename_with_severity) == 0) {
// Assign cleaned_base_filename to our new base name
// Add trailing dot we deleted earlier
cleaned_base_filename = cleaned_base_filename_with_severity + '.';
found_file = true;
break;
}
}

// Return early if the filename doesn't start with `cleaned_base_filename`.
if (filepath.find(cleaned_base_filename) != 0) {
if (!found_file) {
return false;
}

Expand Down

0 comments on commit 4e016e5

Please sign in to comment.