This repository was archived by the owner on Jun 30, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,8 @@ TEST(CleanImmediately, logging) {
61
61
62
62
for (unsigned i = 0 ; i < 1000 ; ++i) {
63
63
LOG (INFO) << " cleanup test" ;
64
+ LOG (WARNING) << " cleanup test" ;
65
+ LOG (ERROR) << " cleanup test" ;
64
66
}
65
67
66
68
google::DisableLogCleaner ();
Original file line number Diff line number Diff line change @@ -1416,8 +1416,30 @@ bool LogCleaner::IsLogFromCurrentProject(
1416
1416
}
1417
1417
}
1418
1418
1419
+ // As we want to delete old logs despite their severity,
1420
+ // we need to replace <severity> in cleaned_base_file and find matching one.
1421
+ const string::size_type dot_pos =
1422
+ cleaned_base_filename.find_last_of (' .' , cleaned_base_filename.size () - 2 );
1423
+
1424
+ const string new_base_filename = cleaned_base_filename.substr (0 , dot_pos + 1 );
1425
+
1426
+ // Loop through severity names and check whether
1427
+ // filepath contains cleaned_base_filename_with_severity
1428
+ bool found_file = false ;
1429
+ for (const auto & severity : LogSeverityNames) {
1430
+ string cleaned_base_filename_with_severity = new_base_filename + severity;
1431
+
1432
+ if (filepath.find (cleaned_base_filename_with_severity) == 0 ) {
1433
+ // Assign cleaned_base_filename to our new base name
1434
+ // Add trailing dot we deleted earlier
1435
+ cleaned_base_filename = cleaned_base_filename_with_severity + ' .' ;
1436
+ found_file = true ;
1437
+ break ;
1438
+ }
1439
+ }
1440
+
1419
1441
// Return early if the filename doesn't start with `cleaned_base_filename`.
1420
- if (filepath. find (cleaned_base_filename) != 0 ) {
1442
+ if (!found_file ) {
1421
1443
return false ;
1422
1444
}
1423
1445
You can’t perform that action at this time.
0 commit comments