Skip to content

Commit

Permalink
Fix copying stack setting in logger's Output method (#325)
Browse files Browse the repository at this point in the history
Minimum example to reproduce the problem:
```go
package main

import (
	"os"

	"github.com/pkg/errors"
	"github.com/rs/zerolog"
	"github.com/rs/zerolog/log"
	"github.com/rs/zerolog/pkgerrors"
)

func main() {
	log.Logger = log.With().Caller().Stack().Logger().Output(zerolog.ConsoleWriter{Out: os.Stderr})
	zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack

	log.Info().Err(errors.New("test")).Send()
}
```
Without my changes `stack` isn't printed.
  • Loading branch information
adw1n committed Jun 7, 2021
1 parent e05605c commit 117cb53
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions log.go
Expand Up @@ -223,6 +223,7 @@ func (l Logger) Output(w io.Writer) Logger {
l2 := New(w)
l2.level = l.level
l2.sampler = l.sampler
l2.stack = l.stack
if len(l.hooks) > 0 {
l2.hooks = append(l2.hooks, l.hooks...)
}
Expand Down

0 comments on commit 117cb53

Please sign in to comment.