log

package
v2.0.5-testnet Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: Apache-2.0, MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InfoLevel  = int(zapcore.InfoLevel)
	DebugLevel = int(zapcore.DebugLevel)
	ErrorLevel = int(zapcore.ErrorLevel)
	FatalLevel = int(zapcore.FatalLevel)
	PanicLevel = int(zapcore.PanicLevel)
	WarnLevel  = int(zapcore.WarnLevel)
)

Variables

View Source
var DefaultLevel = InfoLevel

DefaultLevel is the default level where statements are logged. Change the value of this variable before init() to change the level of the default logger.

Functions

func ConfigureDefaultLogger

func ConfigureDefaultLogger(output zapcore.WriteSyncer, level int, jsonFormat bool)

ConfigureDefaultLogger updates the default logger to wrap a provided kit logger.

func ToContext

func ToContext(ctx context.Context, l Logger) context.Context

ToContext allows setting the logger on the context

Types

type Logger

type Logger interface {
	Info(keyvals ...interface{})
	Debug(keyvals ...interface{})
	Warn(keyvals ...interface{})
	Error(keyvals ...interface{})
	Fatal(keyvals ...interface{})
	Panic(keyvals ...interface{})
	Infow(msg string, keyvals ...interface{})
	Debugw(msg string, keyvals ...interface{})
	Warnw(msg string, keyvals ...interface{})
	Errorw(msg string, keyvals ...interface{})
	Fatalw(msg string, keyvals ...interface{})
	Panicw(msg string, keyvals ...interface{})
	With(args ...interface{}) Logger
	Named(s string) Logger
	AddCallerSkip(skip int) Logger
}

Logger is an interface that can log to different levels.

func DefaultLogger

func DefaultLogger() Logger

DefaultLogger is the default logger that only logs at the `DefaultLevel`.

func FromContextOrDefault

func FromContextOrDefault(ctx context.Context) Logger

FromContextOrDefault returns the logger from the context when set with CtxWithLogger. If not found, it returns a nil value.

func New

func New(output zapcore.WriteSyncer, level int, isJSON bool) Logger

New returns a logger that prints statements at the given level.

Jump to

Keyboard shortcuts

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