zap

package
v0.0.0-...-af2a51d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

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

Example
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")
}
Output:

{"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

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

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

New creates a new instance of logr.Logger.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL