Documentation
¶
Index ¶
- Constants
- Variables
- func AddGatewayStderrHandler(level int) error
- func ClearSessionContext()
- func DrainLogQueue(timeout time.Duration)
- func EnableProfileLogRouting(profileHomes []string) (bool, error)
- func FlushLogQueue()
- func InComponent(name string, packages []string) bool
- func InstallSlogBridge()
- func LevelName(level int) string
- func LogFilePath(ctx context.Context, name string) (string, bool)
- func RedactDetachedStdio() error
- func ReleaseProfileLogHandlers(profileHome string) (int, error)
- func ResetQueuedHandlers()
- func SetSessionContext(sessionID string)
- func SetupHomeLogging(h, mode string) error
- func SetupLogging(ctx context.Context, o Options) (string, error)
- func SetupVerboseLogging() error
- func Shutdown()
- type Filter
- type Formatter
- type Handler
- type Logger
- func (l *Logger) AddHandler(h Handler)
- func (l *Logger) Debug(msg string)
- func (l *Logger) EffectiveLevel() int
- func (l *Logger) Error(msg string)
- func (l *Logger) Exception(msg string, err error)
- func (l *Logger) Handlers() []Handler
- func (l *Logger) Info(msg string)
- func (l *Logger) IsEnabledFor(level int) bool
- func (l *Logger) Level() int
- func (l *Logger) Log(level int, msg string)
- func (l *Logger) LogContext(ctx context.Context, level int, msg string)
- func (l *Logger) Name() string
- func (l *Logger) RemoveHandler(h Handler)
- func (l *Logger) SetLevel(level int)
- func (l *Logger) SetPropagate(on bool)
- func (l *Logger) Slog() *slog.Logger
- func (l *Logger) Warning(msg string)
- type Options
- type Record
- type StreamHandler
Constants ¶
const ( LevelNotSet = 0 LevelDebug = 10 LevelInfo = 20 LevelWarning = 30 LevelError = 40 LevelCritical = 50 )
Variables ¶
var ( RedactingHandler func(next slog.Handler) slog.Handler RedactSensitiveText func(text string) string ResolveProfilePolicy func(home string) )
Hooks pkg/tools sets in an init so formatters and stdio redact the way agent.redact does
var ComponentPrefixes = map[string][]string{
"gateway": {"gateway", "gatewayrun", "gatewayapi"},
"agent": {"agent", "provider", "providerregistry", "memory", "monitoring", "lsp", "i18n", "pet", "trajectorycompressor", "batchrun"},
"tools": {"tools", "media", "mcp", "browser", "codeexec", "skills", "gateway/messagetools"},
"cli": {"cmd/icebath", "app", "commands", "activesessions", "gatewaycli", "goals", "kanban", "selfupdate", "plugins", "profiles", "setupflow"},
"cron": {"cron"},
"gui": {"tuiserver", "tuigateway", "tui"},
}
Packages of each component, gating component logs and logs --component
var LogFiles = map[string]string{
"agent": "agent.log", "errors": "errors.log", "gateway": "gateway.log", "update": "update.log", "mcp": "mcp-stderr.log",
}
Known log files by the name icebath logs takes
var LogTiers = map[string]string{"update": linktier.Extras}
Tier whose code writes a log, update.log being the self updater's, absent for core logs
var RootHomeLogs = []string{"update"}
Logs the root home holds whatever profile is active, in name order
Functions ¶
func AddGatewayStderrHandler ¶
Adds the gateway console handler at level to the root logger, lowering the root level to reach it
func ClearSessionContext ¶
func ClearSessionContext()
Stops tagging the calling goroutine's records with a session id
func DrainLogQueue ¶
Drains the queue for a hard exit, waiting at most timeout for a listener wedged on the rotation lock
func EnableProfileLogRouting ¶
Replaces the queued file handlers with profile routers over homes, true when routing is or already was on
func FlushLogQueue ¶
func FlushLogQueue()
Blocks until every queued record is written, then resumes the listener
func InComponent ¶
Whether a logger name is one of the packages or a package below one of them
func InstallSlogBridge ¶
func InstallSlogBridge()
Routes slog through the logger hierarchy from process start, so a record before setup meets the last resort handler
func LogFilePath ¶
Where a named log lives without checking it exists, false for an unknown name
func RedactDetachedStdio ¶
func RedactDetachedStdio() error
Routes stdout and stderr of a detached process through secret redaction, once per stream
func ReleaseProfileLogHandlers ¶
Closes this process's routed log files below a profile home before the profile is removed
func ResetQueuedHandlers ¶
func ResetQueuedHandlers()
Tears down the queue, the listener and every queued handler
func SetSessionContext ¶
func SetSessionContext(sessionID string)
Tags every record the calling goroutine logs with the session id
func SetupHomeLogging ¶
Configures the log files of home for mode, the setup_logging call a worker process makes at startup
func SetupLogging ¶
Configures the log files of a home and returns its logs directory, a second call a no op unless forced
func SetupVerboseLogging ¶
func SetupVerboseLogging() error
Adds the DEBUG console handler of verbose mode once
Types ¶
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
Renders records through a Python logging format, redacting the whole line when built with the redaction hook
func GatewayStderrFormatter ¶
Redacting formatter of the gateway stderr stream
func LogFileFormatter ¶
Redacting formatter the agent, errors and gateway log files write their lines through
func NewFormatter ¶
Formatter for a printf style format and strftime date format, the default message format when empty
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Named node of the package logger hierarchy with its level, handlers and propagation switch
func GetLogger ¶
Logger for a slash separated package name, the root logger for an empty name or root
func (*Logger) AddHandler ¶
Attaches a handler to this logger
func (*Logger) EffectiveLevel ¶
First level set walking up the hierarchy, zero when none is set
func (*Logger) Exception ¶
Logs msg at ERROR with the error text below it, the error carried on the record for filters
func (*Logger) IsEnabledFor ¶
Reports whether a record at level passes this logger's effective level
func (*Logger) LogContext ¶
Logs msg at level with the record attributes resolved from ctx
func (*Logger) RemoveHandler ¶
Detaches a handler from this logger
func (*Logger) SetPropagate ¶
Turns propagation of records to ancestor handlers on or off
type Options ¶
type Options struct {
Home string
LogLevel string
MaxSizeMB int
BackupCount int
Mode string
Force bool
}
Options of SetupLogging, zero values deferring to config.yaml logging and the built in defaults
type Record ¶
type Record struct {
Name string
Levelno int
Levelname string
Msg string
Created time.Time
SessionTag string
Home string
Thread uint64
PC uintptr
// Error logged with the record, its text already below Msg
ExcInfo error
}
One log event with the attributes the formatters render
type StreamHandler ¶
type StreamHandler interface {
Handler
SetLevel(level int)
AddFilter(f Filter)
Formatter() *Formatter
}
Stream handler whose filters and formatter a caller sets up
func NewRedactingStderrHandler ¶
func NewRedactingStderrHandler(format, datefmt string) (StreamHandler, error)
Handler writing records to stderr through a redacting formatter of the given format