Skip to content

Commit

Permalink
LogCleaner: Fix the scenario when FLAGS_log_dir has no '/' suffix
Browse files Browse the repository at this point in the history
Fixes #971
  • Loading branch information
lingbin committed Oct 10, 2023
1 parent b58718f commit 86056ce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Brian Silverman <[email protected]>
Dmitriy Arbitman <[email protected]>
Google Inc.
Guillaume Dumont <[email protected]>
LingBin <[email protected]>
Marco Wang <[email protected]>
Michael Tanner <[email protected]>
MiniLight <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Håkan L. S. Younes <[email protected]>
Ivan Penkov <[email protected]>
Jacob Trimble <[email protected]>
Jim Ray <[email protected]>
LingBin <[email protected]>
Marco Wang <[email protected]>
Michael Darr <[email protected]>
Michael Tanner <[email protected]>
Expand Down
12 changes: 10 additions & 2 deletions src/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2397,8 +2397,16 @@ const vector<string>& GetLoggingDirectories() {
logging_directories_list = new vector<string>;

if ( !FLAGS_log_dir.empty() ) {
// A dir was specified, we should use it
logging_directories_list->push_back(FLAGS_log_dir);
// A dir was specified, we should use it, and make sure to end with
// a directory delimiter.
const char* const dir_delim_end =
possible_dir_delim + sizeof(possible_dir_delim);
if (std::find(possible_dir_delim, dir_delim_end,
FLAGS_log_dir.back()) == dir_delim_end) {
logging_directories_list->push_back(FLAGS_log_dir + "/");
} else {
logging_directories_list->push_back(FLAGS_log_dir);
}
} else {
GetTempDirectories(logging_directories_list);
#ifdef GLOG_OS_WINDOWS
Expand Down

0 comments on commit 86056ce

Please sign in to comment.