Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LogCleaner: Fix the scenario when FLAGS_log_dir has no '/' suffix #972

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
10 changes: 8 additions & 2 deletions src/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <iterator>
#include <string>

#ifdef HAVE_UNISTD_H
Expand Down Expand Up @@ -2397,8 +2398,13 @@ 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);
// Ensure the specified path ends with a directory delimiter.
if (std::find(std::begin(possible_dir_delim), std::end(possible_dir_delim),
FLAGS_log_dir.back()) == std::end(possible_dir_delim)) {
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