Fix copying stack setting in logger's Output method (#325)

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.
This commit is contained in:
adw1n 2021-06-07 12:16:53 +02:00 committed by GitHub
parent e05605c215
commit 117cb53bc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

1
log.go
View File

@ -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...)
}