Skip to content

Commit

Permalink
Merge pull request #654 from aesophor/fix-path
Browse files Browse the repository at this point in the history
Make LogCleaner support relative paths
  • Loading branch information
sergiud committed Oct 29, 2021
2 parents e8e40f7 + c27c3a8 commit 17e7679
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -478,15 +478,14 @@ class LogFileObject : public base::Logger {
class LogCleaner {
public:
LogCleaner();
virtual ~LogCleaner() {}

void Enable(int overdue_days);
void Disable();
void Run(bool base_filename_selected,
const string& base_filename,
const string& filename_extension) const;

inline bool enabled() const { return enabled_; }
bool enabled() const { return enabled_; }

private:
vector<string> GetOverdueLogNames(string log_directory,
Expand Down Expand Up @@ -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_);
Expand All @@ -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<string> dirs;

Expand Down Expand Up @@ -1362,7 +1359,6 @@ vector<string> 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) {
Expand Down

0 comments on commit 17e7679

Please sign in to comment.