log

package
v0.2.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: AGPL-3.0 Imports: 13 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 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 NewZerologAdapter

func NewZerologAdapter(logger Logger) zapcore.Core

NewZerologAdapter 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 diode 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.

Types

type Logger

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

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

func Component

func Component(component string) Logger

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

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, useDiode bool, levelString string) Logger

NewLogger creates a new logger by wrapping io.Writer in a diode. Make sure to call Logger.Close() once done with this 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 (Logger) Close

func (lg Logger) Close()

Close closes all the underlying diode Writer when there are valid Logger instances.

func (*Logger) Component

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

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

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) 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) 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) 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) Zerolog

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

Zerolog returns underlying zerolog logger.

Jump to

Keyboard shortcuts

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