logger

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package logger provides logging functionality for the application

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyVal

type KeyVal struct {
	Key   string
	Value any
}

KeyVal is a key value pair

func Group

func Group(key string, kvs ...KeyVal) KeyVal

Group creates a new KeyVal with a group of KeyVals

func Value

func Value(key string, value any) KeyVal

Value creates a new KeyVal

type Logger

type Logger interface {
	SetupLogger(env string, conf config.ValidLoggingConfig) error
	With(args ...KeyVal) Logger
	Debug(ctx context.Context, msg string, args ...KeyVal)
	Info(ctx context.Context, msg string, args ...KeyVal)
	Warn(ctx context.Context, msg string, args ...KeyVal)
	Error(ctx context.Context, msg string, args ...KeyVal)
	Close() error
}

Logger is an interface for logging

func NewLoggerFromConfig

func NewLoggerFromConfig(_ string, _ config.ValidLoggingConfig) (Logger, error)

NewLoggerFromConfig creates a new Logger from the config

type SlogLogger

type SlogLogger struct {
	Logger *slog.Logger
	// contains filtered or unexported fields
}

SlogLogger is a logger that uses slog

func NewSlogLogger

func NewSlogLogger() *SlogLogger

NewSlogLogger creates a new SlogLogger

func (*SlogLogger) Close

func (l *SlogLogger) Close() error

Close closes the logger

func (*SlogLogger) Debug

func (l *SlogLogger) Debug(ctx context.Context, msg string, args ...KeyVal)

Debug logs a debug message

func (*SlogLogger) Error

func (l *SlogLogger) Error(ctx context.Context, msg string, args ...KeyVal)

Error logs an error message

func (*SlogLogger) Info

func (l *SlogLogger) Info(ctx context.Context, msg string, args ...KeyVal)

Info logs an info message

func (*SlogLogger) SetupLogger

func (l *SlogLogger) SetupLogger(env string, cfg config.ValidLoggingConfig) error

SetupLogger sets up the logger with the given configuration

func (*SlogLogger) Warn

func (l *SlogLogger) Warn(ctx context.Context, msg string, args ...KeyVal)

Warn logs a warning message

func (*SlogLogger) With

func (l *SlogLogger) With(args ...KeyVal) Logger

With adds attributes to the logger

Jump to

Keyboard shortcuts

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