logger

package
v0.0.0-...-04c4af4 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(v ...interface{})

Debug calls the default logger's Debug method.

func Debugf

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

Debugf calls the default logger's Debugf method.

func Error

func Error(v ...interface{})

Error calls the default logger's Error method.

func Errorf

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

Errorf calls the default logger's Errorf method.

func Info

func Info(v ...interface{})

Info calls the default logger's Info method.

func Infof

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

Infof calls the default logger's Infof method.

func Panic

func Panic(v ...interface{})

Panic calls the default logger's Panic method

func Panicf

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

Panicf calls the default logger's Fatalf method

func SetDefaultLogger

func SetDefaultLogger(l Logger)

SetDefaultLogger sets the default logger. This is not concurrency safe, which means it should only be called during init.

func SetLevel

func SetLevel(lv Level)

SetLevel sets the level of logs below which logs will not be output. The default log level is LevelTrace.

func Warn

func Warn(v ...interface{})

Warn calls the default logger's Warn method.

func Warnf

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

Warnf calls the default logger's Warnf method.

Types

type Fields

type Fields map[string]any

type Level

type Level int

Level defines the priority of a log message. When a logger is configured with a level, any log message with a lower log level (smaller by integer comparison) will not be output.

const (
	LevelDebug Level = iota
	LevelInfo
	LevelWarn
	LevelError
	LevelPanic
)

The levels of logs.

type Logger

type Logger interface {
	Debug(v ...any)
	Info(v ...any)
	Warn(v ...any)
	Error(v ...any)
	Panic(v ...any)

	Debugf(format string, v ...any)
	Infof(format string, v ...any)
	Warnf(format string, v ...any)
	Errorf(format string, v ...any)
	Panicf(format string, v ...any)

	WithField(key string, value any) Logger
	WithFields(fields Fields) Logger
	WithError(err error) Logger
}

Logger is a logger interface that provides logging function with levels.

func DefaultLogger

func DefaultLogger() Logger

func WithError

func WithError(err error) Logger

WithError calls the default logger's WithError method.

func WithField

func WithField(key string, value any) Logger

WithField calls the default logger's WithField method.

func WithFields

func WithFields(fields Fields) Logger

WithFields calls the default logger's WithFields method.

Jump to

Keyboard shortcuts

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