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

Fix rolling file appender bug #6266

Open
wants to merge 9 commits into
base: unstable
Choose a base branch
from

Conversation

eserilev
Copy link
Collaborator

@eserilev eserilev commented Aug 15, 2024

Issue Addressed

Closes #6246

Proposed Changes

Ensures that the file path passed to the rolling file appender only contains directories. This PR iterates through each piece of --logfile and if its a dir, appends it to the file path we use for the rolling file appender. If all or parts of --logfile dont exist yet, we just use the full --logfile path.

@eserilev eserilev added bug Something isn't working ready-for-review The code is ready for review labels Aug 15, 2024
Copy link
Member

@ackintosh ackintosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the issue!

Comment on lines 227 to 241
for p in base_tracing_log_path.iter() {
match metadata(p) {
Ok(metadata) => {
if metadata.is_dir() {
tracing_log_path = tracing_log_path.join(p);
}
}
// An error here just means that part of `base_tracing_log_path` doesn't exist,
// we can safely continue.
Err(_) => {
tracing_log_path = base_tracing_log_path;
break;
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that the for loop unexpectedly breaks in the Err(_) statement when running Lighthouse with the --logfile /Users/akihito/logs/beacon.log parameter. This happens because the strings passed to match metadata(p) are [/, Users, akihito, logs, beacon.log], and the second string, Users (not /Users), doesn't exist in my working directory.

I think we can fix this by making the following change:

    for p in base_tracing_log_path.iter() {
+       tracing_log_path = tracing_log_path.join(p);
+       match tracing_log_path.metadata() {
            Ok(metadata) => {
+               if !metadata.is_dir() {
+                   tracing_log_path.pop();
+                   break;
                }
            }

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for catching that issue! i've pushed up a fix here: f97e0d4

havent had a chance to test it yet, will get to that soon

@michaelsproul michaelsproul added waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed ready-for-review The code is ready for review labels Aug 19, 2024
@michaelsproul michaelsproul added ready-for-review The code is ready for review v6.0.0 New major release for hierarchical state diffs and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready-for-review The code is ready for review v6.0.0 New major release for hierarchical state diffs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants