mlog

package
v1.19.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithLogger

func ContextWithLogger(ctx context.Context, logger Logger) context.Context

ContextWithLogger returns a context within a Logger in "logger" value.

Types

type GoLogger

type GoLogger struct {
	Level LogLevel
	// contains filtered or unexported fields
}

GoLogger is the Go built-in (log) implementation of Logger interface.

func (*GoLogger) Debug

func (l *GoLogger) Debug(args ...any)

Debug implements Debug Logger interface function.

func (*GoLogger) Debugf

func (l *GoLogger) Debugf(format string, args ...any)

Debugf implements Debugf Logger interface function.

func (*GoLogger) Debugln

func (l *GoLogger) Debugln(args ...any)

Debugln implements Debugln Logger interface function.

func (*GoLogger) Error

func (l *GoLogger) Error(args ...any)

Error implements Error Logger interface function.

func (*GoLogger) Errorf

func (l *GoLogger) Errorf(format string, args ...any)

Errorf implements Errorf Logger interface function.

func (*GoLogger) Errorln

func (l *GoLogger) Errorln(args ...any)

Errorln implements Errorln Logger interface function.

func (*GoLogger) Fatal

func (l *GoLogger) Fatal(args ...any)

Fatal implements Fatal Logger interface function.

func (*GoLogger) Fatalf

func (l *GoLogger) Fatalf(format string, args ...any)

Fatalf implements Fatalf Logger interface function.

func (*GoLogger) Fatalln

func (l *GoLogger) Fatalln(args ...any)

Fatalln implements Fatalln Logger interface function.

func (*GoLogger) Info

func (l *GoLogger) Info(args ...any)

Info implements Info Logger interface function.

func (*GoLogger) Infof

func (l *GoLogger) Infof(format string, args ...any)

Infof implements Infof Logger interface function.

func (*GoLogger) Infoln

func (l *GoLogger) Infoln(args ...any)

Infoln implements Infoln Logger interface function.

func (*GoLogger) IsLevelEnabled

func (l *GoLogger) IsLevelEnabled(level LogLevel) bool

IsLevelEnabled checks if the given level is enabled.

func (*GoLogger) Warn

func (l *GoLogger) Warn(args ...any)

Warn implements Warn Logger interface function.

func (*GoLogger) Warnf

func (l *GoLogger) Warnf(format string, args ...any)

Warnf implements Warnf Logger interface function.

func (*GoLogger) Warnln

func (l *GoLogger) Warnln(args ...any)

Warnln implements Warnln Logger interface function.

func (*GoLogger) WithFields

func (l *GoLogger) WithFields(fields ...any) Logger

WithFields implements WithFields Logger interface function

type LogLevel

type LogLevel int8

LogLevel represents the level of log system (fatal, error, warn, info and debug).

const (
	// PanicLevel level, highest level of severity. Logs and then calls panic with the
	// message passed to Debug, Info, ...
	PanicLevel LogLevel = iota
	// FatalLevel level. Logs and then calls `logger.Exit(1)`. It will exit even if the
	// logging level is set to Panic.
	FatalLevel
	// ErrorLevel level. Logs. Used for errors that should definitely be noted.
	// Commonly used for hooks to send errors to an error tracking service.
	ErrorLevel
	// WarnLevel level. Non-critical entries that deserve eyes.
	WarnLevel
	// InfoLevel level. General operational entries about what's going on inside the
	// application.
	InfoLevel
	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
	DebugLevel
)

These are the different log levels. You can set the logging level to log.

func ParseLevel

func ParseLevel(lvl string) (LogLevel, error)

ParseLevel takes a string level and returns a LogLevel constant.

type Logger

type Logger interface {
	Info(args ...any)
	Infof(format string, args ...any)
	Infoln(args ...any)

	Error(args ...any)
	Errorf(format string, args ...any)
	Errorln(args ...any)

	Warn(args ...any)
	Warnf(format string, args ...any)
	Warnln(args ...any)

	Debug(args ...any)
	Debugf(format string, args ...any)
	Debugln(args ...any)

	Fatal(args ...any)
	Fatalf(format string, args ...any)
	Fatalln(args ...any)

	WithFields(fields ...any) Logger
}

Logger is the common interface for log implementation.

func NewLoggerFromContext

func NewLoggerFromContext(ctx context.Context) Logger

NewLoggerFromContext extract the Logger from "logger" value inside context

type NoneLogger

type NoneLogger struct{}

NoneLogger is a wrapper for log nothing.

func (*NoneLogger) Debug

func (l *NoneLogger) Debug(args ...any)

Debug implements Debug Logger interface function.

func (*NoneLogger) Debugf

func (l *NoneLogger) Debugf(format string, args ...any)

Debugf implements Debugf Logger interface function.

func (*NoneLogger) Debugln

func (l *NoneLogger) Debugln(args ...any)

Debugln implements Debugln Logger interface function.

func (*NoneLogger) Error

func (l *NoneLogger) Error(args ...any)

Error implements Error Logger interface function.

func (*NoneLogger) Errorf

func (l *NoneLogger) Errorf(format string, args ...any)

Errorf implements Errorf Logger interface function.

func (*NoneLogger) Errorln

func (l *NoneLogger) Errorln(args ...any)

Errorln implements Errorln Logger interface function.

func (*NoneLogger) Fatal

func (l *NoneLogger) Fatal(args ...any)

Fatal implements Fatal Logger interface function.

func (*NoneLogger) Fatalf

func (l *NoneLogger) Fatalf(format string, args ...any)

Fatalf implements Fatalf Logger interface function.

func (*NoneLogger) Fatalln

func (l *NoneLogger) Fatalln(args ...any)

Fatalln implements Fatalln Logger interface function.

func (*NoneLogger) Info

func (l *NoneLogger) Info(args ...any)

Info implements Info Logger interface function.

func (*NoneLogger) Infof

func (l *NoneLogger) Infof(format string, args ...any)

Infof implements Infof Logger interface function.

func (*NoneLogger) Infoln

func (l *NoneLogger) Infoln(args ...any)

Infoln implements Infoln Logger interface function.

func (*NoneLogger) Warn

func (l *NoneLogger) Warn(args ...any)

Warn implements Warn Logger interface function.

func (*NoneLogger) Warnf

func (l *NoneLogger) Warnf(format string, args ...any)

Warnf implements Warnf Logger interface function.

func (*NoneLogger) Warnln

func (l *NoneLogger) Warnln(args ...any)

Warnln implements Warnln Logger interface function.

func (*NoneLogger) WithFields

func (l *NoneLogger) WithFields(fields ...any) Logger

WithFields implements WithFields Logger interface function

Jump to

Keyboard shortcuts

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