logger

package
v3.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClientField    = "c"
	DirectionField = "d"
	MarkNone       = " "
	MarkIn         = "←"
	MarkOut        = "→"
	MarkPlus       = "+"
	MarkCross      = "x"
)

Variables

This section is empty.

Functions

func SetGlobalLevel

func SetGlobalLevel(l Level)

Types

type Level

type Level int8

Level defines log levels.

const (
	DebugLevel Level = iota
	InfoLevel
	WarnLevel
	ErrorLevel
	FatalLevel
	PanicLevel
	NoLevel
	Disabled
	TraceLevel Level = -1
)

func (Level) String

func (l Level) String() string

type Logger

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

func Default

func Default() *Logger

func New

func New(isDebug bool) *Logger

func NewConsole

func NewConsole(isDebug bool, tag string, noColor bool) *Logger

func (*Logger) Debug

func (l *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) Error

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

Error starts a new message with error level.

func (*Logger) Extend

func (l *Logger) Extend(ctx zerolog.Context) *Logger

Extend adds some additional context to the existing logger.

func (*Logger) Fatal

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

Fatal starts a new message with fatal level. The os.Exit(1) function is called by the Msg method. You must call Msg on the returned event in order to send the event.

func (*Logger) GetLevel

func (l *Logger) GetLevel() Level

GetLevel returns the current Level of l.

func (*Logger) Hook

func (l *Logger) Hook(h zerolog.Hook) zerolog.Logger

Hook returns a logger with the h Hook.

func (*Logger) Info

func (l *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) Level

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

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

func (*Logger) Log

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

Log starts a new message with no level. Setting zerolog.GlobalLevel to zerolog.Disabled will still disable events produced by this method. You must call Msg on the returned event in order to send the event.

func (*Logger) Output

func (l *Logger) Output(w io.Writer) zerolog.Logger

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

func (*Logger) Panic

func (l *Logger) 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 (*Logger) Print

func (l *Logger) Print(v ...any)

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 (l *Logger) Printf(format string, v ...any)

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

func (*Logger) Sample

func (l *Logger) Sample(s zerolog.Sampler) zerolog.Logger

Sample returns a logger with the s sampler.

func (*Logger) Trace

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

func (*Logger) Warn

func (l *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) With

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

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

func (*Logger) WithLevel

func (l *Logger) 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.

Jump to

Keyboard shortcuts

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