Skip to content

Conversation

john-michaelburke
Copy link
Collaborator

@john-michaelburke john-michaelburke commented Jan 7, 2022

  • Attempts to create the current logging directory when the app starts up.
    • Previously directories would only be created if a change in the target logging directory was initiated.
  • Also replaces double backslashes with forward slashes when printing pathbufs in a few places.

@john-michaelburke john-michaelburke force-pushed the john-michaelburke/CPP-407 branch 2 times, most recently from 96d65b5 to 6671d54 Compare January 7, 2022 18:49
@john-michaelburke john-michaelburke force-pushed the john-michaelburke/CPP-407 branch from 6671d54 to 6aef1b3 Compare January 7, 2022 18:57
@john-michaelburke john-michaelburke marked this pull request as ready for review January 7, 2022 19:07
@john-michaelburke john-michaelburke requested a review from a team January 7, 2022 19:14
@john-michaelburke john-michaelburke changed the title Always create initial SwiftNav directory.[CPP-407] Always create initial logging directory.[CPP-407] Jan 7, 2022
Some(logger)
}
Err(e) => {
error!("issue creating file, {:?}, error, {}", sbp_log_file, e);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not 100% certain but I think the double slashes are due to using the Debug to format the path. I think using Path::display would give you single slashes.

                        error!("issue creating file, {}, error, {}", sbp_json_log_file.display(), e);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You were 100% correct this make for a much cleaner solution thank you!


/// Formats a pathbuf replacing double backslahes with single forward slashes.
pub fn pathbuf_to_unix_filepath(path: PathBuf) -> PathBuf {
PathBuf::from(path.to_string_lossy().replace("\\", "/"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Forward slashes are not the typical path separator for Windows. Whatever we implement should display a single backslash for Windows.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that is the behavior of Path::display, single forward slash on unix and single backslash on windows. I think the double slash is just the Debug impl showing you the escape character

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I switched to using .display for all occurrences I could find throughout the app.

@john-michaelburke john-michaelburke force-pushed the john-michaelburke/CPP-407 branch from 1a00fb4 to 4997a36 Compare January 7, 2022 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants