logging

package
v0.0.0-...-af8b0af Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2025 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LoggerConfigSet  = config.New("logger").WithValidate(validateLogger)
	ReportCallerFlag = LoggerConfigSet.Bool("log.report-caller", false, "Whenever or not to output the file that outputs the log")
	LevelFlag        = LoggerConfigSet.String("log.level", "info", "The debug level, levels are: debug, info, warn, error, fatal")
	FormatFlag       = LoggerConfigSet.String("log.format", "text", "The format of the logging")
)

Functions

func Context

func Context(ctx context.Context, logger *log.Logger) context.Context

Context updates the given logger with the updated logger

func Debug

func Debug(ctx context.Context, msg interface{}, keyvals ...interface{})

Debug logs a message at the debug level using the logger from the context.

func Debugf

func Debugf(ctx context.Context, format string, args ...interface{})

Debugf logs a formatted message at the debug level using the logger from the context.

func Error

func Error(ctx context.Context, msg interface{}, keyvals ...interface{})

Error logs a message at the error level using the logger from the context.

func Errorf

func Errorf(ctx context.Context, format string, args ...interface{})

Errorf logs a formatted message at the error level using the logger from the context.

func From

func From(ctx context.Context) *log.Logger

From returns the possible injected logger in the context

func FromPrefix

func FromPrefix(ctx context.Context, prefix string) *log.Logger

From returns the possible injected logger in the context, adding the given format

func Info

func Info(ctx context.Context, msg interface{}, keyvals ...interface{})

Info logs a message at the info level using the logger from the context.

func Infof

func Infof(ctx context.Context, format string, args ...interface{})

Infof logs a formatted message at the info level using the logger from the context.

func ReportIf

func ReportIf(msg string, call func() error)

func SetupLogger

func SetupLogger()

func Slog

func Slog() *slog.Logger

func ToSlog

func ToSlog(logger *log.Logger) *slog.Logger

func ToWriter

func ToWriter(logger *log.Logger, opts ...log.StandardLogOptions) io.Writer

func UpdateLogger

func UpdateLogger(reportCaller bool, level, format string)

func Warn

func Warn(ctx context.Context, msg interface{}, keyvals ...interface{})

Warn logs a message at the warning level using the logger from the context.

func Warnf

func Warnf(ctx context.Context, format string, args ...interface{})

Warnf logs a formatted message at the warning level using the logger from the context.

func With

func With(ctx context.Context, keyvals ...interface{}) *log.Logger

With returns a logger with the given key-value pairs attached, based on the logger extracted from the provided context.

func WithPrefix

func WithPrefix(ctx context.Context, prefix string) *log.Logger

WithPrefix returns a logger with the given prefix attached, based on the logger extracted from the provided context.

func Writer

func Writer(opts ...log.StandardLogOptions) io.Writer

Types

type Enriched

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

func (Enriched) From

func (p Enriched) From(ctx context.Context) *log.Logger

func (Enriched) FromUpdate

func (p Enriched) FromUpdate(ctx context.Context) (*log.Logger, context.Context)

func (Enriched) With

func (e Enriched) With(keyvalues ...interface{}) Enriched

func (Enriched) WithPrefix

func (e Enriched) WithPrefix(prefix string) Enriched

Jump to

Keyboard shortcuts

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