Skip to content

fix: normalize paths on windows#74

Merged
Stebalien merged 2 commits intomasterfrom
fix/log-path-windows
Mar 24, 2020
Merged

fix: normalize paths on windows#74
Stebalien merged 2 commits intomasterfrom
fix/log-path-windows

Conversation

@Stebalien
Copy link
Copy Markdown
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
@Stebalien Stebalien requested a review from aschmahmann March 24, 2020 05:09
Copy link
Copy Markdown

@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
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)
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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`.
@Stebalien Stebalien force-pushed the fix/log-path-windows branch from a92dbe3 to 45b384f Compare March 24, 2020 05:45
Copy link
Copy Markdown

@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
@gammazero gammazero deleted the fix/log-path-windows branch May 6, 2025 19:01
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