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: normalize paths on windows #74

Merged
merged 2 commits into from
Mar 24, 2020
Merged

fix: normalize paths on windows #74

merged 2 commits into from
Mar 24, 2020

Conversation

Stebalien
Copy link
Member

Fixes #73 by normalizing paths to UNC on windows. This is slightly less hacky than registering a new schema.

The underlying issue was twofold:

  1. When specifying a windows file URL as file://c:/foo/bar, go barfs because : can't be in a domain name.
  2. When specifying a windows file URL as file:///c:/foo/bar, we'd end up trying to open /c:/foo/bar which is actually CURRENT_DRIVE:/c:/foo/bar.

@Stebalien Stebalien force-pushed the fix/log-path-windows branch 4 times, most recently from 2009645 to a92dbe3 Compare March 24, 2020 05:07
Copy link

@willscott willscott left a comment

Choose a reason for hiding this comment

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

that's very unfortunate that windows needs that!

setup.go Outdated
@@ -68,7 +68,11 @@ func SetupLogging() {
zapCfg.OutputPaths = []string{"stderr"}
// check if we log to a file
if logfp := os.Getenv(envLoggingFile); len(logfp) > 0 {
zapCfg.OutputPaths = append(zapCfg.OutputPaths, logfp)
if path, err := normalizePath(logfp); err != nil {
fmt.Fprintf(os.Stderr, "error normalizing log path '%q': %s\n", logfp, err)

Choose a reason for hiding this comment

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

should output paths revert to just stderr in this case? that doesn't seem obvious based on the printed error.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm. Yeah, it probably should.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, that's what happens. I guess I can just add that to the message.

Fixes #73 by normalizing paths to UNC on windows. This is _slightly_ less hacky
than registering a new schema.

The underlying issue was twofold:

1. When specifying a windows file URL as `file://c:/foo/bar`, go barfs because
`:` can't be in a domain name.
2. When specifying a windows file URL as `file:///c:/foo/bar`, we'd end up
trying to open `/c:/foo/bar` which is actually `CURRENT_DRIVE:/c:/foo/bar`.
Copy link

@jacobheun jacobheun left a comment

Choose a reason for hiding this comment

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

Verified logging the benchmark tests to file on windows works

@Stebalien Stebalien merged commit 6277577 into master Mar 24, 2020
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.

Windows Support
4 participants