logger

package
v0.0.0-...-b891794 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelDebug = Level(slog.LevelDebug)
	LevelInfo  = Level(slog.LevelInfo)
	LevelWarn  = Level(slog.LevelWarn)
	LevelError = Level(slog.LevelError)
)

A set of possible logging levels.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventFn

type EventFn func(ctx context.Context, r Record)

EventFn is a function to be executed when configured against a log level.

type Events

type Events struct {
	Debug EventFn
	Info  EventFn
	Warn  EventFn
	Error EventFn
}

Events contains an assignment of an event function to a log level.

type Level

type Level slog.Level

Level represents different logging levels.

type Logger

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

func New

func New(w io.Writer, minLevel Level, serviceName string, traceIDFn TraceIDFn) *Logger

func NewWithEvents

func NewWithEvents(
	w io.Writer,
	minLevel Level,
	serviceName string,
	traceIDFn TraceIDFn,
	events Events,
) *Logger

func NewWithHandler

func NewWithHandler(h slog.Handler) *Logger

func (*Logger) Debug

func (log *Logger) Debug(ctx context.Context, msg string, args ...any)

func (*Logger) Error

func (log *Logger) Error(ctx context.Context, msg string, args ...any)

func (*Logger) Info

func (log *Logger) Info(ctx context.Context, msg string, args ...any)

func (*Logger) Warn

func (log *Logger) Warn(ctx context.Context, msg string, args ...any)

type Record

type Record struct {
	Time       time.Time
	Message    string
	Level      Level
	Attributes map[string]any
}

Record represents the data that is being logged.

type TraceIDFn

type TraceIDFn func(ctx context.Context) string

Jump to

Keyboard shortcuts

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