Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLogFilePath ¶
GetLogFilePath returns the resolved log file path. If logConfig.File is empty, it returns the default "activity.log".
func IterAttrs ¶
IterAttrs walks through the attributes in the context. The return value is compatible with iter.Seq[slog.Attr] to allow range func.
Example:
for attr := range slogutil.IterAttrs(ctx) {
// DO SOMETHING
}
Feature description: https://tip.golang.org/wiki/RangefuncExperiment
Types ¶
type DynamicLeveler ¶
type DynamicLeveler struct {
// contains filtered or unexported fields
}
func SetupLogRotation ¶
func SetupLogRotation(logConfig config.LogConfig) (*slog.Logger, *DynamicLeveler)
SetupLogRotation configures slog with log rotation using lumberjack. Always logs to both stdout (text format) and a file (JSON format). The file path defaults to "activity.log" if logConfig.File is empty. Returns the logger and a DynamicLeveler for runtime level changes.
func SetupLogRotationWithFallback ¶
func SetupLogRotationWithFallback(logConfig config.LogConfig, legacyLogLevel string) (*slog.Logger, *DynamicLeveler)
SetupLogRotationWithFallback sets up log rotation with backward compatibility It checks both new log config and legacy log_level setting
func (*DynamicLeveler) Level ¶
func (dl *DynamicLeveler) Level() slog.Level
Level returns the current logging level.
func (*DynamicLeveler) SetLevel ¶
func (dl *DynamicLeveler) SetLevel(level slog.Level)
SetLevel updates the logging level.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is a slog.Handler with hooks support.
func WrapHandler ¶
WrapHandler creates a new Handler with the given slog.Handler. If the provided handler is nil, a default JSON handler is used.