zap

package
v0.0.0-...-a4d05e0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Duration = zap.Duration
View Source
var Error = zap.Error
View Source
var Int = zap.Int
View Source
var String = zap.String

Re-export relevant zap functions

View Source
var Strings = zap.Strings

Functions

func AnyFields

func AnyFields(keysAndValues ...interface{}) []zap.Field

AnyFields creates a slice of Any fields from a key, value sequence

func Cid

func Cid(key string, c mh.Multihash) zapcore.Field

func Cids

func Cids(key string, cids ...mh.Multihash) zapcore.Field

func Fields

func Fields(fields ...zapcore.Field) []zapcore.Field

Fields avoids referencing zapcore when creating []zapcore.Field

func Multiaddrs

func Multiaddrs(key string, mas ...multiaddr.Multiaddr) zapcore.Field

func PeerID

func PeerID(key string, id peer.ID) zapcore.Field

func PeerIDs

func PeerIDs(key string, ids ...peer.ID) zapcore.Field

func Percent

func Percent(key string, p int) zapcore.Field

func ShortCid

func ShortCid(cid mh.Multihash) string

Types

type Logger

type Logger struct {
	*zap.Logger
}

Logger embeds zap.Logger so that it inherits its public functions.

func NewDevelopmentLogger

func NewDevelopmentLogger(debug bool, json bool) (*Logger, error)

NewDevelopmentLogger is used for testing.

func NewLogger

func NewLogger(opts *Options) (*Logger, error)

NewLogger is the primary logger constructor.

func (*Logger) Named

func (l *Logger) Named(name string) *Logger

Named needs to rewrap the result so that zap.Logger doesn't leak out.

func (*Logger) With

func (l *Logger) With(field zap.Field) *Logger

With needs to rewrap the result so that zap.Logger doesn't leak out.

type Options

type Options struct {
	Level    string `long:"level" description:"Log level. Support values: error, warn, info, debug" default:"info"`
	Encoding string `long:"encoding" description:"Log encoding format. Support values: console, json" default:"console"`
}

Jump to

Keyboard shortcuts

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