don't trim leading slash on callers outside cwd (#266)
Fixes https://github.com/rs/zerolog/issues/265
This commit is contained in:
parent
9336c4d0ed
commit
cac3894be4
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue