log

package
v0.4.12 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Registry = &LoggerRegistry{
	loggers:              make(map[string]*slog.Logger),
	suppressedComponents: make(map[string]bool),
}

Global registry instance

Functions

func Auth

func Auth() *slog.Logger

func ClientAPI added in v0.4.1

func ClientAPI() *slog.Logger

func ClientCache added in v0.4.1

func ClientCache() *slog.Logger

func ClientConnection added in v0.4.1

func ClientConnection() *slog.Logger

func ClientCore added in v0.4.1

func ClientCore() *slog.Logger

func ClientData added in v0.4.1

func ClientData() *slog.Logger

func ClientMain added in v0.4.1

func ClientMain() *slog.Logger

func ClientSession added in v0.4.1

func ClientSession() *slog.Logger

func ClientTools added in v0.4.1

func ClientTools() *slog.Logger

func Close

func Close() *slog.Logger

func Config

func Config() *slog.Logger

func Event

func Event() *slog.Logger

func EventStore

func EventStore() *slog.Logger

func GetAllComponents added in v0.4.1

func GetAllComponents() []string

GetAllComponents returns a slice of all component names used by the logger functions

func GetLogger

func GetLogger(component string) *slog.Logger

The GetLogger function now simply delegates to the registry

func InitializeLoggers

func InitializeLoggers(cfg *cfgType.ServerConfig)

InitializeLoggers sets up the central logging system with the given configuration

func Log

func Log() *slog.Logger

func Mongo

func Mongo() *slog.Logger

func MongoPurge

func MongoPurge() *slog.Logger

func MongoQuery

func MongoQuery() *slog.Logger

func MongoStore

func MongoStore() *slog.Logger

func RelayAPI added in v0.4.1

func RelayAPI() *slog.Logger

func RelayClient added in v0.4.1

func RelayClient() *slog.Logger

func RelayConnection added in v0.4.1

func RelayConnection() *slog.Logger

func Req

func Req() *slog.Logger

func StartPeriodicLogTrimmer

func StartPeriodicLogTrimmer(logFilePath string, maxSizeMB int, checkIntervalMinutes int, backupCount int)

StartPeriodicLogTrimmer starts a goroutine that periodically checks and manages log size

func Startup added in v0.4.1

func Startup() *slog.Logger

All logging components defined in one place

func UserSync

func UserSync() *slog.Logger

func Util

func Util() *slog.Logger

func Validation

func Validation() *slog.Logger

Types

type JSONLogWriter

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

JSONLogWriter writes logs in a pretty-printed JSON array format

func NewJSONLogWriter

func NewJSONLogWriter(filePath string, level slog.Level, maxSizeMB int, backupCount int, suppressedComponents map[string]bool) *JSONLogWriter

NewJSONLogWriter creates a new instance of JSONLogWriter

func (*JSONLogWriter) Close

func (j *JSONLogWriter) Close()

Close is now a no-op since logs are written properly on each entry.

func (*JSONLogWriter) Enabled

func (j *JSONLogWriter) Enabled(ctx context.Context, level slog.Level) bool

Required interface methods for slog.Handler

func (*JSONLogWriter) Handle

func (j *JSONLogWriter) Handle(ctx context.Context, r slog.Record) error

Handle writes logs in JSON format

func (*JSONLogWriter) WithAttrs

func (j *JSONLogWriter) WithAttrs(attrs []slog.Attr) slog.Handler

func (*JSONLogWriter) WithGroup

func (j *JSONLogWriter) WithGroup(name string) slog.Handler

type LoggerRegistry

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

LoggerRegistry maintains a map of all loggers by component name

func (*LoggerRegistry) Get

func (r *LoggerRegistry) Get(component string) *slog.Logger

Get returns a logger for the specified component

type PrettyLogWriter

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

PrettyLogWriter writes logs ONLY to a file

func (*PrettyLogWriter) Enabled

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

Required interface methods for slog.Handler

func (*PrettyLogWriter) Handle

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

Handle writes logs to the log file

func (*PrettyLogWriter) WithAttrs

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

func (*PrettyLogWriter) WithGroup

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

Jump to

Keyboard shortcuts

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