From c27c3a803bf0ee6396ce5f69fce766d4f211431d Mon Sep 17 00:00:00 2001 From: Marco Wang Date: Mon, 17 May 2021 23:35:37 +0800 Subject: [PATCH] make LogCleaner support relative paths --- src/logging.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/logging.cc b/src/logging.cc index b6625616b..824a60ed6 100644 --- a/src/logging.cc +++ b/src/logging.cc @@ -478,7 +478,6 @@ class LogFileObject : public base::Logger { class LogCleaner { public: LogCleaner(); - virtual ~LogCleaner() {} void Enable(int overdue_days); void Disable(); @@ -486,7 +485,7 @@ class LogCleaner { const string& base_filename, const string& filename_extension) const; - inline bool enabled() const { return enabled_; } + bool enabled() const { return enabled_; } private: vector GetOverdueLogNames(string log_directory, @@ -1296,9 +1295,6 @@ void LogFileObject::Write(bool force_flush, // Remove old logs if (log_cleaner.enabled()) { - if (base_filename_selected_ && base_filename_.empty()) { - return; - } log_cleaner.Run(base_filename_selected_, base_filename_, filename_extension_); @@ -1324,6 +1320,7 @@ void LogCleaner::Run(bool base_filename_selected, const string& base_filename, const string& filename_extension) const { assert(enabled_ && overdue_days_ >= 0); + assert(!base_filename_selected || !base_filename.empty()); vector dirs; @@ -1362,7 +1359,6 @@ vector LogCleaner::GetOverdueLogNames(string log_directory, DIR *dir; struct dirent *ent; - if ((dir = opendir(log_directory.c_str()))) { while ((ent = readdir(dir))) { if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) {