log

package
v0.0.0-...-a84335b Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package log provides logging functions and middleware

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestLogger

func RequestLogger(next http.Handler) http.Handler

func SetDefaults

func SetDefaults(d LoggerOptions)

SetDefaults will set the logger options used when creating a default logger

Types

type Logger

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

Logger is a logging handler instance.

func Default

func Default() *Logger

Default returns a logger instance using the configured defaults.

func FromContext

func FromContext(ctx context.Context) *Logger

FromContext returns the logger instance from a context If the logger is unset, a default logger is returned

func New

func New(opts LoggerOptions) *Logger

New creates a new Logger instance

func (*Logger) Debug

func (l *Logger) Debug(msg string, args ...any)

Debug logs at level DEBUG. args are treated as key-value pairs.

func (*Logger) DebugEnabled

func (l *Logger) DebugEnabled() bool

DebugEnabled checks if Debug level logging is enabled

func (*Logger) Error

func (l *Logger) Error(msg string, err error, args ...any)

Error logs at level ERROR. If the error arg is non-nil, it will be appended to the attributes under key "err"

func (*Logger) Info

func (l *Logger) Info(msg string, args ...any)

Info logs a level INFO. Args are treated as key-value pairs.

func (*Logger) WithString

func (l *Logger) WithString(key, value string) *Logger

WithString adds a string valued attribute to the logger context. All logs produced with this logger will include the new attribute.

type LoggerOptions

type LoggerOptions struct {
	Debug bool
	JSON  bool
}

LoggerOptions provide the options for customizing the behavior New Logger instances.

Jump to

Keyboard shortcuts

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