Skip to content

Commit

Permalink
fix short log
Browse files Browse the repository at this point in the history
  • Loading branch information
zetaab committed Jan 20, 2024
1 parent 60feca7 commit 7124816
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions log/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func NewDefaultEnvLogger(opts ...Opt) *slog.Logger {
WithOutput(os.Stdout),
WithSource(ParseSourceFromEnv()),
WithShortSource(true),
WithReplacer(nil),
}

opts = append(defaults, opts...)
Expand Down Expand Up @@ -67,8 +66,8 @@ func WithShortSource(short bool) Opt {
if short {
b.opts.ReplaceAttr = func(s []string, a slog.Attr) slog.Attr {
if a.Key == slog.SourceKey {
source, _ := a.Value.Any().(*slog.Source)
if source != nil {
source, ok := a.Value.Any().(*slog.Source)
if ok && source != nil {
source.File = filepath.Base(source.File)
}
}
Expand Down

0 comments on commit 7124816

Please sign in to comment.