logging

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 19, 2025 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultLogFilePath

func GetDefaultLogFilePath() string

GetDefaultLogFilePath returns the default log file path

func SetupLogger

func SetupLogger(logFilePath string, level slog.Level) (*slog.Logger, io.Closer, error)

SetupLogger configures a file-based logger

Types

type FileLogger

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

FileLogger implements slog.Handler to write logs to a file

func NewFileLogger

func NewFileLogger(filePath string, level slog.Level, opts *slog.HandlerOptions) (*FileLogger, error)

NewFileLogger creates a new handler that writes logs to the specified file path If the file exists, it will append to it

func (*FileLogger) Close

func (h *FileLogger) Close() error

Close closes the log file

func (*FileLogger) Enabled

func (h *FileLogger) Enabled(ctx context.Context, level slog.Level) bool

Enabled reports whether the handler handles records at the given level

func (*FileLogger) Handle

func (h *FileLogger) Handle(ctx context.Context, r slog.Record) error

Handle processes the log record

func (*FileLogger) WithAttrs

func (h *FileLogger) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs creates a new Handler with the given attributes

func (*FileLogger) WithGroup

func (h *FileLogger) WithGroup(name string) slog.Handler

WithGroup creates a new Handler with the given group

type PrettyHandler

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

PrettyHandler implements slog.Handler with kr/pretty formatting

func (*PrettyHandler) Enabled

func (h *PrettyHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*PrettyHandler) Handle

func (h *PrettyHandler) Handle(ctx context.Context, r slog.Record) error

func (*PrettyHandler) WithAttrs

func (h *PrettyHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*PrettyHandler) WithGroup

func (h *PrettyHandler) WithGroup(name string) slog.Handler

Jump to

Keyboard shortcuts

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