Back to godoc.org

Package zap

v0.0.0-...-4521796
Latest Go to latest

The latest major version is .

Published: Sep 17, 2018 | License: MIT | Module: github.com/corvus-ch/logr

Overview

Package zap implements logr.Logger by Tim Hockin using the Zap logger by Uber.

Example

Code:

package main

import (
	log "github.com/corvus-ch/logr/zap"
	"go.uber.org/zap"
)

func main() {
	l := log.New(1, zap.NewExample())
	l.Info("Info level log message")
	l.Infof("%X", "Info level log message printed in hex values")
	l.Error("Error level log message")
	l.Errorf("%X", "Error level log message printed in hex values")
	l.NewWithPrefix("adipiscing").Info("This message has a prefix field")
	l.V(1).Info("This message will be printed with debug level")
	l.V(1).Infof("%X", "This message will be printed with debug level as hex values")
	l.V(2).Info("This message will not be printed as its verbosity exceeds the maximum")
}
{"level":"info","msg":"Info level log message"}
{"level":"info","msg":"496E666F206C6576656C206C6F67206D657373616765207072696E74656420696E206865782076616C756573"}
{"level":"error","msg":"Error level log message"}
{"level":"error","msg":"4572726F72206C6576656C206C6F67206D657373616765207072696E74656420696E206865782076616C756573"}
{"level":"info","msg":"This message has a prefix field","prefix":"adipiscing"}
{"level":"debug","msg":"This message will be printed with debug level"}
{"level":"debug","msg":"54686973206D6573736167652077696C6C206265207072696E7465642077697468206465627567206C6576656C206173206865782076616C756573"}

Index

Examples

func New

func New(verbosity int, l *zap.Logger) *logger

New creates a new instance of logr.Logger.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier