logging

package
v0.0.0-...-9c85fd6 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: BSD-3-Clause Imports: 11 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 HttpMiddleware

func HttpMiddleware(next http.Handler) http.Handler

HttpMiddleware is a middleware that logs the incoming HTTP requests

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 InjectTrace

func InjectTrace(logger *log.Logger, span trace.Span) *log.Logger

InjectTrace returns a logger with trace information (trace ID and span ID) attached.

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 WithTrace

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

WithTrace returns a logger with trace information (trace ID and span ID) attached, based on the logger extracted from the provided context and the current span from the context. If no valid span is present in the context, returns the logger without trace information.

func Writer

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

Types

type Enriched

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

func (Enriched) Debug

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

Debug prints a debug message.

func (Enriched) Debugf

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

Debugf prints a debug message with formatting.

func (Enriched) Error

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

Error prints an error message.

func (Enriched) Errorf

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

Errorf prints an error message with formatting.

func (Enriched) Fatal

func (l Enriched) Fatal(ctx context.Context, msg interface{}, keyvals ...interface{})

Fatal prints a fatal message and exits.

func (Enriched) Fatalf

func (l Enriched) Fatalf(ctx context.Context, format string, args ...interface{})

Fatalf prints a fatal message with formatting and exits.

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

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

Info prints an info message.

func (Enriched) Infof

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

Infof prints an info message with formatting.

func (Enriched) Print

func (l Enriched) Print(ctx context.Context, msg interface{}, keyvals ...interface{})

Print prints a message with no level.

func (Enriched) Printf

func (l Enriched) Printf(ctx context.Context, format string, args ...interface{})

Printf prints a message with no level and formatting.

func (Enriched) Warn

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

Warn prints a warning message.

func (Enriched) Warnf

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

Warnf prints a warning message with formatting.

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