Creates an opinionated zap logger.
Shall you at some point need to pass a logr.Logger
instance in your code, e.g. while writing code that uses the
Kubernetes client library etc., you can use go-logr/zapr
to wrap the logger, as follows:
package main
import (
"github.com/go-logr/zapr"
"github.com/postfinance/flash"
)
func main() {
l := flash.New()
z := zapr.NewLogger(l.Desugar())
z.V(0).Info("I'm a zap logger complying with logr.Logger interface !")
}
Debug / Info / Error
2020-10-09T09:29:06.363+0200 INFO test/main.go:26 message {"StackTrace": "off", "debug": false}
2020-10-09T09:29:06.364+0200 ERROR test/main.go:27 message {"StackTrace": "off", "debug": false}
Debug / Info / Error
2020-10-09T09:29:06.364+0200 DEBUG test/main.go:33 message {"StackTrace": "off", "debug": true}
2020-10-09T09:29:06.364+0200 INFO test/main.go:34 message {"StackTrace": "off", "debug": true}
2020-10-09T09:29:06.364+0200 ERROR test/main.go:35 message {"StackTrace": "off", "debug": true}
Debug / Info / Error
2020-10-09T09:29:06.364+0200 INFO test/main.go:42 message {"StackTrace": "off", "debug": false}
2020-10-09T09:29:06.364+0200 ERROR test/main.go:43 message {"StackTrace": "off", "debug": false}
Fatal
2020-10-09T09:29:06.364+0200 FATAL test/main.go:47 message {"StackTrace": "on", "debug": false}
exit status 1
Debug / Info / Error
2020-10-09T09:29:11.889+0200 INFO test/main.go:26 message {"StackTrace": "off", "debug": false}
2020-10-09T09:29:11.889+0200 ERROR test/main.go:27 message {"StackTrace": "off", "debug": false}
Debug / Info / Error
2020-10-09T09:29:11.889+0200 DEBUG test/main.go:33 message {"StackTrace": "off", "debug": true}
2020-10-09T09:29:11.889+0200 INFO test/main.go:34 message {"StackTrace": "off", "debug": true}
2020-10-09T09:29:11.889+0200 ERROR test/main.go:35 message {"StackTrace": "off", "debug": true}
main.main
/export/home/sauterm/tmp/test/main.go:35
runtime.main
/export/home/sauterm/.gimme/versions/go1.15.2.linux.amd64/src/runtime/proc.go:204
Debug / Info / Error
2020-10-09T09:29:11.889+0200 INFO test/main.go:42 message {"StackTrace": "off", "debug": false}
2020-10-09T09:29:11.889+0200 ERROR test/main.go:43 message {"StackTrace": "off", "debug": false}
Fatal
2020-10-09T09:29:11.889+0200 FATAL test/main.go:47 message {"StackTrace": "on", "debug": false}
main.main
/export/home/sauterm/tmp/test/main.go:47
runtime.main
/export/home/sauterm/.gimme/versions/go1.15.2.linux.amd64/src/runtime/proc.go:204
exit status 1