Documentation
¶
Overview ¶
Package logging provides structured file logging with a bash-compatible format.
BracketHandler implements slog.Handler and produces output in the format:
[2024-01-15 10:30:00] [INFO] message
This matches the log format from the original bash SSU script.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitLogger ¶
InitLogger creates a slog.Logger that writes to a rotating log file.
The log file is created at logDir/submodule-update.log and rotated by lumberjack when it exceeds maxSizeMB megabytes, keeping up to maxBackups old files.
When verbose is true, a second handler writes DEBUG+ output to stderr. When verbose is false, only INFO+ goes to the file and nothing to stderr.
Types ¶
type BracketHandler ¶
type BracketHandler struct {
// contains filtered or unexported fields
}
BracketHandler is a slog.Handler that writes log records in bracket format. It is safe for concurrent use.
func NewBracketHandler ¶
func NewBracketHandler(w io.Writer, level slog.Level) *BracketHandler
NewBracketHandler creates a BracketHandler that writes to w at the given level.
func (*BracketHandler) Enabled ¶
Enabled reports whether the handler handles records at the given level.
type MultiHandler ¶
type MultiHandler struct {
// contains filtered or unexported fields
}
MultiHandler fans out log records to multiple slog.Handler implementations.
func (*MultiHandler) Enabled ¶
Enabled reports whether any of the underlying handlers is enabled for the level.