-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 can not delete old logs #971
Comments
I've traced the issue and it should be a bug of glog. I will add the reason analysis later and submit a PR to fix it later. |
Because
But unfortunately, I found that both will indeed print logs to the "/tmp/glogs/" directory, but if there is no
The biggest difference between the two is the value of filePath in line 6 above, which is also the reason for this bug.
Short summary: here |
After further exploring the code, I found that the problem came from the following places: Lines 1430 to 1434 in b58718f
When Lines 1470 to 1473 in b58718f
In order to solve this problem, we only need to modify the if (!log_directory.empty()) {
if (std::find(possible_dir_delim, dir_delim_end,
log_directory[log_directory.size() - 1]) == dir_delim_end) {
filepath = log_directory + '/' + filepath;
} else {
filepath = log_directory + filepath;
}
} I will follow https://github.com/google/glog#how-to-contribute and submit a PR as soon as possible. |
Update:
What needs to be noted here is that In this unit test, the following code is included: google::SetLogDestination(GLOG_INFO, "test_cleanup_");
After further exploration, I found that there are some difficulties in our current processing of directories, especially the judgment of whether it ends with Lines 1388 to 1399 in b58718f
Whether
However, regardless of the processing method here, I suggest that we should normalize the input value of This is exactly what I modified in the final PR I submitted. The problem I encountered will also be solved, and all existing unit tests will succeed. |
glog version: 0.6.0
My simplified reproduction process is as follows:
It is set above to delete files that are more than 3 days old, but they are not deleted.
The text was updated successfully, but these errors were encountered: