logger

package
v0.0.0-...-e400c07 Latest Latest
Warning

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

Go to latest
Published: May 1, 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)
)

logging categories in use

Variables

This section is empty.

Functions

This section is empty.

Types

type EventFunc

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

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

type Events

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

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

type Level

type Level slog.Level

level represents different different log categories

type Logger

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

Logger is responsible for logging the messages

func NewWithEvents

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

NewWithEvents constructs a Logger for application use with events.

func (*Logger) Info

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

Info logs at LevelInfo with the given context.

func (*Logger) Infoc

func (log *Logger) Infoc(ctx context.Context, caller int, msg string, args ...any)

Infoc logs the information at the specified call stack position.

type Record

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

the data to be logged

type TraceIDFunc

type TraceIDFunc func(ctx context.Context) string

TraceIDFunc is a declaration for a function that returns the trace id from the passed context

Jump to

Keyboard shortcuts

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