Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Commit eab31bd

Browse files
committed
enable, disable generic logs. export the functions to be used
1 parent 6927d55 commit eab31bd

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

src/glog/logging.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,10 @@ InstallFailureFunction(logging_fail_func_t fail_func);
485485
GLOG_EXPORT void EnableLogCleaner(const std::chrono::minutes& overdue);
486486
GLOG_EXPORT void DisableLogCleaner();
487487
GLOG_EXPORT void SetApplicationFingerprint(const std::string& fingerprint);
488+
GLOG_EXPORT void EnableLogCleaner(LogSeverity severity, const std::chrono::minutes& overdue);
489+
GLOG_EXPORT void DisableLogCleaner(LogSeverity severity);
490+
GLOG_EXPORT void EnableLogCleanerForGenericLogs(const std::chrono::minutes& overdue);
491+
GLOG_EXPORT void DisableLogCleanerForGenericLogs();
488492

489493
class LogSink; // defined below
490494

src/logging.cc

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,9 @@ class LogCleaner {
450450
void Enable(const LogSeverity severity, const std::chrono::minutes& overdue);
451451
void Disable();
452452
void Disable(const LogSeverity severity);
453+
// For files with no severity in their names
454+
void EnableForGenericLogs(const std::chrono::minutes& overdue);
455+
void DisableForGenericLogs();
453456

454457
void Run(const std::chrono::system_clock::time_point& current_time,
455458
bool base_filename_selected, const string& base_filename,
@@ -1295,11 +1298,11 @@ void LogFileObject::Write(
12951298
LogCleaner::LogCleaner() = default;
12961299

12971300
void LogCleaner::Enable(const std::chrono::minutes& overdue) {
1298-
// for the files that have no severity specified
1299-
overdue_[-1] = overdue;
1300-
// for backward compatability, set all severities to the same value
1301+
// For the files that have no severity specified, we use -1 as the key
1302+
EnableForGenericLogs(overdue);
1303+
// For backward compatability, set all severities to the same value
13011304
for (int i = GLOG_INFO; i < NUM_SEVERITIES; i++) {
1302-
overdue_[i] = overdue;
1305+
Enable(static_cast<LogSeverity>(i), overdue);
13031306
}
13041307
}
13051308

@@ -1313,6 +1316,14 @@ void LogCleaner::Disable(const LogSeverity severity) {
13131316
overdue_.erase(severity);
13141317
}
13151318

1319+
void LogCleaner::EnableForGenericLogs(const std::chrono::minutes& overdue) {
1320+
overdue_[-1] = overdue;
1321+
}
1322+
1323+
void LogCleaner::DisableForGenericLogs() {
1324+
overdue_.erase(-1);
1325+
}
1326+
13161327
void LogCleaner::Run(const std::chrono::system_clock::time_point& current_time,
13171328
bool base_filename_selected, const string& base_filename,
13181329
const string& filename_extension) {
@@ -2659,12 +2670,20 @@ void EnableLogCleaner(LogSeverity severity, const std::chrono::minutes& overdue)
26592670
log_cleaner.Enable(severity, overdue);
26602671
}
26612672

2673+
void EnableLogCleanerForGenericLogs(const std::chrono::minutes& overdue) {
2674+
log_cleaner.EnableForGenericLogs(overdue);
2675+
}
2676+
26622677
void DisableLogCleaner() { log_cleaner.Disable(); }
26632678

26642679
void DisableLogCleaner(LogSeverity severity) {
26652680
log_cleaner.Disable(severity);
26662681
}
26672682

2683+
void DisableLogCleanerForGenericLogs() {
2684+
log_cleaner.DisableForGenericLogs();
2685+
}
2686+
26682687
LogMessageTime::LogMessageTime() = default;
26692688

26702689
namespace {

0 commit comments

Comments
 (0)