don't trim leading slash on callers outside cwd (#266)

Fixes https://github.com/rs/zerolog/issues/265
This commit is contained in:
Jason McVetta 2020-11-02 19:52:51 +07:00 committed by GitHub
parent 9336c4d0ed
commit cac3894be4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -358,8 +358,8 @@ func consoleDefaultFormatCaller(noColor bool) Formatter {
if len(c) > 0 { if len(c) > 0 {
cwd, err := os.Getwd() cwd, err := os.Getwd()
if err == nil { if err == nil {
c = strings.TrimPrefix(c, cwd) prefix := cwd + "/"
c = strings.TrimPrefix(c, "/") c = strings.TrimPrefix(c, prefix)
} }
c = colorize(c, colorBold, noColor) + colorize(" >", colorCyan, noColor) c = colorize(c, colorBold, noColor) + colorize(" >", colorCyan, noColor)
} }