logging

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Provides a transition layer from "github.com/op/go-logging" to "go.uber.org/zap" to simply resolve some reentrancy issues in go-logging.

This provides a largely api compatible layer so we can quickly drop in a replacement.

Index

Constants

View Source
const (
	DEBUG    = zapcore.DebugLevel
	INFO     = zapcore.InfoLevel
	WARNING  = zapcore.WarnLevel
	NOTICE   = zapcore.InfoLevel // Map to info
	ERROR    = zapcore.ErrorLevel
	CRITICAL = zapcore.DPanicLevel
)

Mapping of go-logging to zap log levels. It's imperfect but good enough

Variables

This section is empty.

Functions

func GetLevel

func GetLevel(name string) zapcore.Level

GetLevel on a named logger

func SetLevel

func SetLevel(l zapcore.Level, name string)

SetLevel on a named logger

Types

type ZapLogger

type ZapLogger struct {
	// contains filtered or unexported fields
}

Zaplogger is a container to wrap zap logging with the parts of the go-logging API we use

func MustGetLogger

func MustGetLogger(name string) *ZapLogger

MustGetLogger returns a new logger or panic()s

func (*ZapLogger) Debug

func (z *ZapLogger) Debug(args ...interface{})

Debug logs it's arguments at log level Debug

func (*ZapLogger) Debugf

func (z *ZapLogger) Debugf(template string, args ...interface{})

Debugf logs a formatted string at log level Debug

func (*ZapLogger) Error

func (z *ZapLogger) Error(args ...interface{})

Error logs it's arguments at log level Error

func (*ZapLogger) Errorf

func (z *ZapLogger) Errorf(template string, args ...interface{})

Errorf logs a formatted string at log level Error

func (*ZapLogger) Fatal

func (z *ZapLogger) Fatal(args ...interface{})

Fatal logs it's arguments at log level Fatal

func (*ZapLogger) Fatalf

func (z *ZapLogger) Fatalf(template string, args ...interface{})

Fatalf logs a formatted string at log level Fatal and will then always exit()

func (*ZapLogger) GetLevel

func (z *ZapLogger) GetLevel() zapcore.Level

GetLevel returns the log level at which we will log

func (*ZapLogger) Info

func (z *ZapLogger) Info(args ...interface{})

Info logs it's arguments at log level Info

func (*ZapLogger) Infof

func (z *ZapLogger) Infof(template string, args ...interface{})

Infof logs a formatted string at log level Info

func (*ZapLogger) IsEnabledFor

func (z *ZapLogger) IsEnabledFor(level zapcore.Level) bool

IsEnabledFor returns true if logging is enabled for the specified level

func (*ZapLogger) Logger

func (z *ZapLogger) Logger() *zap.Logger

Logger returns the internal zap logger

func (*ZapLogger) Notice

func (z *ZapLogger) Notice(args ...interface{})

Notice logs it's arguments at log level *Info*

func (*ZapLogger) Noticef

func (z *ZapLogger) Noticef(template string, args ...interface{})

Noticef logs a formatted string at log level *Info*

func (*ZapLogger) SetConfigAndRebuild

func (z *ZapLogger) SetConfigAndRebuild(c zap.Config) error

SetConfigAndRebuild so you can replace the default config

func (*ZapLogger) SetLevel

func (z *ZapLogger) SetLevel(l zapcore.Level)

SetLevel sets the log level at which we will log

func (*ZapLogger) SetLogger

func (z *ZapLogger) SetLogger(l *zap.Logger)

SetLogger sets the internal zap logger

func (*ZapLogger) SetSugar

func (z *ZapLogger) SetSugar(s *zap.SugaredLogger)

SetSugar sets our internal Sugared logger

func (*ZapLogger) Sugar

func (z *ZapLogger) Sugar() *zap.SugaredLogger

Sugar returns the internal Sugared logger

func (*ZapLogger) Warning

func (z *ZapLogger) Warning(args ...interface{})

Warning logs it's arguments at log level Warning

func (*ZapLogger) Warningf

func (z *ZapLogger) Warningf(template string, args ...interface{})

Warningf logs a formatted string at log level Warning

Jump to

Keyboard shortcuts

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