improved logging
This commit is contained in:
parent
f8407162ad
commit
05b41cedce
81 changed files with 9802 additions and 279 deletions
41
vendor/github.com/go-logr/zerologr/README.md
generated
vendored
Normal file
41
vendor/github.com/go-logr/zerologr/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
# Zerologr
|
||||
|
||||
[](https://pkg.go.dev/github.com/go-logr/zerologr)
|
||||

|
||||
[](https://goreportcard.com/report/github.com/go-logr/zerologr)
|
||||
|
||||
A [logr](https://github.com/go-logr/logr) LogSink implementation using [Zerolog](https://github.com/rs/zerolog).
|
||||
|
||||
## Usage
|
||||
|
||||
```go
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
"github.com/go-logr/zerologr"
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
func main() {
|
||||
zerolog.TimeFieldFormat = zerolog.TimeFormatUnixMs
|
||||
zerologr.NameFieldName = "logger"
|
||||
zerologr.NameSeparator = "/"
|
||||
|
||||
zl := zerolog.New(os.Stderr)
|
||||
zl = zl.With().Caller().Timestamp().Logger()
|
||||
var log logr.Logger = zerologr.New(&zl)
|
||||
|
||||
log.Info("Logr in action!", "the answer", 42)
|
||||
}
|
||||
```
|
||||
|
||||
## Implementation Details
|
||||
|
||||
For the most part, concepts in Zerolog correspond directly with those in logr.
|
||||
|
||||
Levels in logr correspond to custom debug levels in Zerolog. Any given level
|
||||
in logr is represents by `zerologLevel = 1 - logrLevel`.
|
||||
|
||||
For example `V(2)` is equivalent to Zerolog's `TraceLevel`, while `V(1)` is
|
||||
equivalent to Zerolog's `DebugLevel`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue