MCPcopy Create free account
hub / github.com/apache/impala / DeleteExcessLogFiles

Function DeleteExcessLogFiles

be/src/kudu/util/logging.cc:378–398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

376}
377
378Status DeleteExcessLogFiles(Env* env) {
379 int32_t max_log_files = FLAGS_max_log_files;
380 // Ignore bad input or disable log rotation.
381 if (max_log_files <= 0) return Status::OK();
382
383 for (int severity = 0; severity < google::NUM_SEVERITIES; ++severity) {
384 // Build glob pattern for input
385 // e.g. /var/log/kudu/kudu-master.*.INFO.*
386 string pattern = strings::Substitute("$0/$1.*.$2.*", FLAGS_log_dir, FLAGS_log_filename,
387 google::GetLogSeverityName(severity));
388
389 // Keep the 'max_log_files' most recent log files, as compared by
390 // modification time. Glog files contain a second-granularity timestamp in
391 // the name, so this could potentially use the filename sort order as
392 // guaranteed by glob, however this code has been adapted from Impala which
393 // uses mtime to determine which files to delete, and there haven't been any
394 // issues in production settings.
395 RETURN_NOT_OK(env_util::DeleteExcessFilesByPattern(env, pattern, max_log_files));
396 }
397 return Status::OK();
398}
399
400// Support for the special THROTTLE_MSG token in a log message stream.
401ostream& operator<<(ostream &os, const PRIVATE_ThrottleMsg& /*unused*/) {

Callers

nothing calls this directly

Calls 3

OKFunction · 0.85
SubstituteFunction · 0.85

Tested by

no test coverage detected