logger

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextFieldExtractor

type ContextFieldExtractor func(ctx context.Context) []loggerApi.Attribute

ContextFieldExtractor is a function that receives a context and should return a slice of loggerApi.Attribute to be added into every log call.

type Logger

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

func New

func New(options Options) *Logger

New creates a new Logger interface for applications.

func (*Logger) Debug

func (l *Logger) Debug(ctx context.Context, msg string, attrs ...loggerApi.Attribute)

Debug outputs messages using debug level.

func (*Logger) Debugf

func (l *Logger) Debugf(ctx context.Context, msg string, attrs ...map[string]interface{})

func (*Logger) DisableDebugMessages

func (l *Logger) DisableDebugMessages()

DisableDebugMessages is a helper method to disable Debug level messages.

func (*Logger) Error

func (l *Logger) Error(ctx context.Context, msg string, attrs ...loggerApi.Attribute)

Error outputs messages using error level.

func (*Logger) Errorf

func (l *Logger) Errorf(ctx context.Context, msg string, attrs ...map[string]interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(ctx context.Context, msg string, attrs ...loggerApi.Attribute)

Fatal outputs message using fatal level.

func (*Logger) Fatalf

func (l *Logger) Fatalf(ctx context.Context, msg string, attrs ...map[string]interface{})

func (*Logger) Info

func (l *Logger) Info(ctx context.Context, msg string, attrs ...loggerApi.Attribute)

Info outputs messages using the info level.

func (*Logger) Infof

func (l *Logger) Infof(ctx context.Context, msg string, attrs ...map[string]interface{})

func (*Logger) InnerLogger

func (l *Logger) InnerLogger() *slog.Logger

func (*Logger) Internal

func (l *Logger) Internal(ctx context.Context, msg string, attrs ...loggerApi.Attribute)

Internal outputs messages using the internal level.

func (*Logger) Internalf

func (l *Logger) Internalf(ctx context.Context, msg string, attrs ...map[string]interface{})

func (*Logger) Level

func (l *Logger) Level() string

Level gets the current log level.

func (*Logger) SetContextFieldExtractor

func (l *Logger) SetContextFieldExtractor(extractor ContextFieldExtractor)

SetContextFieldExtractor adds a custom function to extract values from the context and add them into the log messages.

func (*Logger) SetErrorStacktrace

func (l *Logger) SetErrorStacktrace(enabled bool)

SetErrorStacktrace lets one enable or disable the runtime stacktrace that error messages can show.

func (*Logger) SetLogLevel

func (l *Logger) SetLogLevel(level string) (string, error)

SetLogLevel changes the current messages log level.

func (*Logger) Warn

func (l *Logger) Warn(ctx context.Context, msg string, attrs ...loggerApi.Attribute)

Warn outputs messages using warning level.

func (*Logger) Warnf

func (l *Logger) Warnf(ctx context.Context, msg string, attrs ...map[string]interface{})

type Options

type Options struct {
	TextOutput             bool
	LogOnlyFatalLevel      bool
	DisableErrorStacktrace bool
	FixedAttributes        map[string]string
}

Jump to

Keyboard shortcuts

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