log

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 13 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 DB added in v0.5.0

func DB() *slog.Logger

func DBPurge added in v0.5.0

func DBPurge() *slog.Logger

func DBQuery added in v0.5.0

func DBQuery() *slog.Logger

func DBStore added in v0.5.0

func DBStore() *slog.Logger

func Event

func Event() *slog.Logger

func GetAllComponents added in v0.4.1

func GetAllComponents() []string

GetAllComponents returns every component name emitted by the functions above. Keep this in sync with them — it's the source the dashboard and config validation read.

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 NewMultiHandler added in v0.6.0

func NewMultiHandler(handlers ...slog.Handler) slog.Handler

NewMultiHandler returns a slog.Handler that fans Handle/WithAttrs/ WithGroup calls out to all provided handlers. nil entries are skipped.

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

Logging components, defined in one place. Each function names the component it logs under; GetAllComponents below MUST list exactly these names (it drives the dashboard's per-component suppression and the config validation).

DB components: "db" is general nostrdb lifecycle (open/close/duplicate checks), "db-store" writes/deletes, "db-query" reads (incl. search + count), "db-purge" retention (scheduled purge + expiration). The nostrdb package calls these functions — there are no ad-hoc GetLogger("...") component strings outside this file, so this list is authoritative.

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