Code refactoring for bpa operator
[icn.git] / cmd / bpa-operator / vendor / github.com / go-logr / zapr / README.md
1 Zapr :zap:
2 ==========
3
4 A [logr](https://github.com/go-logr/logr) implementation using
5 [Zap](go.uber.org/zap).
6
7 Usage
8 -----
9
10 ```go
11 import (
12     "fmt"
13
14     "go.uber.org/zap"
15     "github.com/go-logr/logr"
16     "github.com/directxman12/zapr"
17 )
18
19 func main() {
20     var log logr.Logger
21
22     zapLog, err := zap.NewDevelopment()
23     if err != nil {
24         panic(fmt.Sprintf("who watches the watchmen (%v)?", err))
25     }
26     log = zapr.NewLogger(zapLog)
27
28     log.Info("Logr in action!", "the answer", 42)
29 }
30 ```
31
32 Implementation Details
33 ----------------------
34
35 For the most part, concepts in Zap correspond directly with those in logr.
36
37 Unlike Zap, all fields *must* be in the form of suggared fields --
38 it's illegal to pass a strongly-typed Zap field in a key position to any
39 of the logging methods (`Log`, `Error`).
40
41 Levels in logr correspond to custom debug levels in Zap.  Any given level
42 in logr is represents by its inverse in Zap (`zapLevel = -1*logrLevel`).
43
44 For example `V(2)` is equivalent to log level -2 in Zap, while `V(1)` is
45 equivalent to Zap's `DebugLevel`.