Skip to content

Commit

Permalink
doc: update readme to use os-specific path separator (#534)
Browse files Browse the repository at this point in the history
* update readme to use os-specific path separator
* shorten getShortLineNo example to one liner
  • Loading branch information
youming-lin authored Mar 2, 2024
1 parent bda298d commit 54ebf46
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,15 +412,7 @@ Equivalent of `Lshortfile`:

```go
zerolog.CallerMarshalFunc = func(pc uintptr, file string, line int) string {
short := file
for i := len(file) - 1; i > 0; i-- {
if file[i] == '/' {
short = file[i+1:]
break
}
}
file = short
return file + ":" + strconv.Itoa(line)
return filepath.Base(file) + ":" + strconv.Itoa(line)
}
log.Logger = log.With().Caller().Logger()
log.Info().Msg("hello world")
Expand Down

0 comments on commit 54ebf46

Please sign in to comment.