log

package
v0.10.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: AGPL-3.0 Imports: 14 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// DebugLevel defines debug log level.
	DebugLevel = zerolog.DebugLevel
	// InfoLevel defines info log level.
	InfoLevel = zerolog.InfoLevel
	// WarnLevel defines warn log level.
	WarnLevel = zerolog.WarnLevel
	// ErrorLevel defines error log level.
	ErrorLevel = zerolog.ErrorLevel
	// FatalLevel defines fatal log level.
	FatalLevel = zerolog.FatalLevel
	// PanicLevel defines panic log level.
	PanicLevel = zerolog.PanicLevel
	// NoLevel defines an absent log level.
	NoLevel = zerolog.NoLevel
	// Disabled disables the logger.
	Disabled = zerolog.Disabled
	// TraceLevel defines trace log level.
	TraceLevel = zerolog.TraceLevel
)

Variables

This section is empty.

Functions

func Debug

func Debug() *zerolog.Event

Debug starts a new message with debug level.

You must call Msg on the returned event in order to send the event.

func Debugf

func Debugf(format string, v ...interface{})

Debugf sends a log event using debug level and no extra field. Arguments are handled in the manner of fmt.Printf.

func Debugln

func Debugln(v ...interface{})

Debugln sends a log event using debug level and no extra field. Arguments are handled in the manner of fmt.Println.

func Error

func Error() *zerolog.Event

Error starts a new message with error level.

You must call Msg on the returned event in order to send the event.

func Errorf

func Errorf(format string, v ...interface{})

Errorf sends a log event using error level and no extra field. Arguments are handled in the manner of fmt.Printf.

func Errorln

func Errorln(v ...interface{})

Errorln sends a log event using error level and no extra field. Arguments are handled in the manner of fmt.Println.

func Fatal

func Fatal() *zerolog.Event

Fatal starts a new message with fatal level.

You must call Msg on the returned event in order to send the event.

func Fatalf

func Fatalf(format string, v ...interface{})

Fatalf sends a log event using fatal level and no extra field. Arguments are handled in the manner of fmt.Printf.

func Fatalln

func Fatalln(v ...interface{})

Fatalln sends a log event using fatal level and no extra field. Arguments are handled in the manner of fmt.Println.

func GetLevel added in v0.3.0

func GetLevel() zerolog.Level

GetLevel returns the global logger level.

func GetPrettyConsoleWriter added in v0.3.0

func GetPrettyConsoleWriter() io.Writer

GetPrettyConsoleWriter returns a pretty console writer.

func Info

func Info() *zerolog.Event

Info starts a new message with info level.

You must call Msg on the returned event in order to send the event.

func Infof

func Infof(format string, v ...interface{})

Infof sends a log event using info level and no extra field. Arguments are handled in the manner of fmt.Printf.

func Infoln

func Infoln(v ...interface{})

Infoln sends a log event using info level and no extra field. Arguments are handled in the manner of fmt.Println.

func Log

func Log() *zerolog.Event

Log starts a new message with no level. This is equivalent to using WithLevel(NoLevel).

You must call Msg on the returned event in order to send the event.

func NewZapAdapter added in v0.3.0

func NewZapAdapter(logger *Logger, component string) zapcore.Core

NewZapAdapter returns a new zapcore Core logger interface that converts given logger's io.writer to WriteSyncer.

func Panic

func Panic() *zerolog.Event

Panic starts a new message with panic level. The message is also sent to the panic function.

You must call Msg on the returned event in order to send the event.

func Panicf

func Panicf(format string, v ...interface{})

Panicf sends a log event using panic level and no extra field. Arguments are handled in the manner of fmt.Printf.

func Panicln

func Panicln(v ...interface{})

Panicln sends a log event using panic level and no extra field. Arguments are handled in the manner of fmt.Println.

func Print

func Print(v ...interface{})

Print sends a log event using debug level and no extra field. Arguments are handled in the manner of fmt.Print.

func Printf

func Printf(format string, v ...interface{})

Printf sends a log event using debug level and no extra field. Arguments are handled in the manner of fmt.Printf.

func Println

func Println(v ...interface{})

Println sends a log event using debug level and no extra field. Arguments are handled in the manner of fmt.Println.

func SetGlobalLevel

func SetGlobalLevel(level zerolog.Level)

SetGlobalLevel sets the global log level with given level.

func SetGlobalLevelString

func SetGlobalLevelString(levelString string) error

SetGlobalLevelString parses given levelString and sets the global log level.

func SetGlobalLogger

func SetGlobalLogger(lg *Logger)

SetGlobalLogger closes the previous global logger and sets given logger as a new global logger.

func SetStdLogger

func SetStdLogger(lg *Logger)

SetStdLogger sets output for the standard logger.

func Trace

func Trace() *zerolog.Event

Trace starts a new message with trace level.

You must call Msg on the returned event in order to send the event.

func WaitFlush

func WaitFlush()

WaitFlush waits a few ms to let the the buffer to flush.

func Warn

func Warn() *zerolog.Event

Warn starts a new message with warn level.

You must call Msg on the returned event in order to send the event.

func Warnf

func Warnf(format string, v ...interface{})

Warnf sends a log event using warn level and no extra field. Arguments are handled in the manner of fmt.Printf.

func Warnln

func Warnln(v ...interface{})

Warnln sends a log event using warn level and no extra field. Arguments are handled in the manner of fmt.Println.

func With

func With() zerolog.Context

With creates a child logger of the global logger with the field added to its context.

func WithLevel

func WithLevel(level zerolog.Level) *zerolog.Event

WithLevel starts a new message with level.

You must call Msg on the returned event in order to send the event.

func Write added in v0.3.0

func Write(p []byte) (n int, err error)

Write implements io.Writer interface.

Types

type Logger

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

Logger is wrapper around zerolog.Logger and io.writers.

func GetGlobalLogger

func GetGlobalLogger() *Logger

GetGlobalLogger returns the global logger.

func Hook

func Hook(hook zerolog.Hook) *Logger

Hook returns the global logger with the h hook.

func Level

func Level(level zerolog.Level) *Logger

Level creates a child logger of the global logger with the minimum accepted level set to level.

func NewDefaultLogger

func NewDefaultLogger() *Logger

NewDefaultLogger creates a new default logger with default settings.

func NewLogger

func NewLogger(w io.Writer, levelString string) *Logger

NewLogger creates a new logger.

func Output

func Output(w io.Writer) *Logger

Output duplicates the global logger and sets w as its output.

func Sample

func Sample(sampler zerolog.Sampler) *Logger

Sample returns the global logger with the s sampler.

func WithBool added in v0.3.0

func WithBool(key string, value bool) *Logger

WithBool adds a bool to the global logger context.

func WithComponent added in v0.3.0

func WithComponent(component string) *Logger

WithComponent enables the global logger to chain loggers with additional context, component name.

func WithInterface added in v0.3.0

func WithInterface(key string, value interface{}) *Logger

WithInterface adds an interface to the global logger context.

func WithStr added in v0.3.0

func WithStr(key string, value string) *Logger

WithStr adds a string to the global logger context.

func (*Logger) Debug

func (lg *Logger) Debug() *zerolog.Event

Debug starts a new message with debug level.

You must call Msg on the returned event in order to send the event.

func (*Logger) Debugf

func (lg *Logger) Debugf(format string, v ...interface{})

Debugf sends a log event using debug level and no extra field. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Debugln

func (lg *Logger) Debugln(v ...interface{})

Debugln sends a log event using debug level and no extra field. Arguments are handled in the manner of fmt.Println.

func (*Logger) Error

func (lg *Logger) Error() *zerolog.Event

Error starts a new message with error level.

You must call Msg on the returned event in order to send the event.

func (*Logger) Errorf

func (lg *Logger) Errorf(format string, v ...interface{})

Errorf sends a log event using error level and no extra field. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Errorln

func (lg *Logger) Errorln(v ...interface{})

Errorln sends a log event using error level and no extra field. Arguments are handled in the manner of fmt.Println.

func (*Logger) Fatal

func (lg *Logger) Fatal() *zerolog.Event

Fatal starts a new message with fatal level. This is an alias for Panic.

You must call Msg on the returned event in order to send the event.

func (*Logger) Fatalf

func (lg *Logger) Fatalf(format string, v ...interface{})

Fatalf sends a log event using fatal level and no extra field. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Fatalln

func (lg *Logger) Fatalln(v ...interface{})

Fatalln sends a log event using fatal level and no extra field. Arguments are handled in the manner of fmt.Println.

func (*Logger) GetLevel added in v0.3.0

func (lg *Logger) GetLevel() zerolog.Level

GetLevel returns the current logger level.

func (*Logger) GetZerolog added in v0.3.0

func (lg *Logger) GetZerolog() *zerolog.Logger

GetZerolog returns underlying zerolog logger.

func (*Logger) Hook

func (lg *Logger) Hook(hook zerolog.Hook) *Logger

Hook returns the current logger with the h hook.

func (*Logger) Info

func (lg *Logger) Info() *zerolog.Event

Info starts a new message with info level.

You must call Msg on the returned event in order to send the event.

func (*Logger) Infof

func (lg *Logger) Infof(format string, v ...interface{})

Infof sends a log event using info level and no extra field. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Infoln

func (lg *Logger) Infoln(v ...interface{})

Infoln sends a log event using info level and no extra field. Arguments are handled in the manner of fmt.Println.

func (*Logger) Level

func (lg *Logger) Level(level zerolog.Level) *Logger

Level creates a child logger of the current logger with the minimum accepted level set to level.

func (*Logger) Log

func (lg *Logger) Log() *zerolog.Event

Log starts a new message with no level. This is equivalent to using lg.WithLevel(NoLevel).

You must call Msg on the returned event in order to send the event.

func (*Logger) NewFromZerolog added in v0.3.0

func (lg *Logger) NewFromZerolog(logger *zerolog.Logger) *Logger

NewFromZerolog creates the logger from zerolog instance.

func (*Logger) Output

func (lg *Logger) Output(w io.Writer) *Logger

Output duplicates the current logger and sets w as its output.

func (*Logger) Panic

func (lg *Logger) Panic() *zerolog.Event

Panic starts a new message with panic level. The panic() function is called by the Msg method, which stops the ordinary flow of a goroutine and invokes any registered PanicHandler.

You must call Msg on the returned event in order to send the event.

func (*Logger) Panicf

func (lg *Logger) Panicf(format string, v ...interface{})

Panicf sends a log event using panic level and no extra field. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Panicln

func (lg *Logger) Panicln(v ...interface{})

Panicln sends a log event using panic level and no extra field. Arguments are handled in the manner of fmt.Println.

func (*Logger) Print

func (lg *Logger) Print(v ...interface{})

Print sends a log event using debug level and no extra field. Arguments are handled in the manner of fmt.Print.

func (*Logger) Printf

func (lg *Logger) Printf(format string, v ...interface{})

Printf sends a log event using debug level and no extra field. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Println

func (lg *Logger) Println(v ...interface{})

Println sends a log event using debug level and no extra field. Arguments are handled in the manner of fmt.Println.

func (*Logger) Sample

func (lg *Logger) Sample(sampler zerolog.Sampler) *Logger

Sample returns the current logger with the s sampler.

func (*Logger) Trace

func (lg *Logger) Trace() *zerolog.Event

Trace starts a new message with trace level.

You must call Msg on the returned event in order to send the event.

func (*Logger) Warn

func (lg *Logger) Warn() *zerolog.Event

Warn starts a new message with warn level.

You must call Msg on the returned event in order to send the event.

func (*Logger) Warnf

func (lg *Logger) Warnf(format string, v ...interface{})

Warnf sends a log event using warn level and no extra field. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Warnln

func (lg *Logger) Warnln(v ...interface{})

Warnln sends a log event using warn level and no extra field. Arguments are handled in the manner of fmt.Println.

func (*Logger) With

func (lg *Logger) With() zerolog.Context

With creates a child logger of the current logger with the field added to its context.

func (*Logger) WithBool added in v0.3.0

func (lg *Logger) WithBool(key string, value bool) *Logger

WithBool adds a bool to the logger context.

func (*Logger) WithComponent added in v0.3.0

func (lg *Logger) WithComponent(component string) *Logger

WithComponent enables the current logger to chain loggers with additional context, component name.

func (*Logger) WithInterface added in v0.3.0

func (lg *Logger) WithInterface(key string, value interface{}) *Logger

WithInterface adds an interface to the logger context.

func (*Logger) WithLevel

func (lg *Logger) WithLevel(level zerolog.Level) *zerolog.Event

WithLevel starts a new message with level. Unlike Fatal and Panic methods, WithLevel does not terminate the program or stop the ordinary flow of a goroutine when used with their respective levels.

You must call Msg on the returned event in order to send the event.

func (*Logger) WithStr added in v0.3.0

func (lg *Logger) WithStr(key string, value string) *Logger

WithStr adds a string to the logger context.

func (*Logger) Write added in v0.3.0

func (lg *Logger) Write(p []byte) (n int, err error)

Write implements io.Writer interface.

Jump to

Keyboard shortcuts

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