Documentation
¶
Overview ¶
Package logging provides log interception functionality for the TUI.
Index ¶
- type Interceptor
- func (l *Interceptor) Close() error
- func (l *Interceptor) Enabled(ctx context.Context, level slog.Level) bool
- func (l *Interceptor) FlushBuffer()
- func (l *Interceptor) Handle(ctx context.Context, record slog.Record) error
- func (l *Interceptor) WithAttrs(attrs []slog.Attr) slog.Handler
- func (l *Interceptor) WithGroup(name string) slog.Handler
- type Msg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interceptor ¶
type Interceptor struct {
// contains filtered or unexported fields
}
Interceptor wraps an slog.Handler to intercept log messages and send them to the TUI. It also optionally writes logs to a file in verbose mode.
func NewInterceptor ¶
func NewInterceptor( originalHandler slog.Handler, program *tea.Program, logFilePath string, suppressStderr bool, ) (*Interceptor, error)
NewInterceptor creates a log interceptor that sends logs to the TUI. If logFilePath is not empty, logs will also be written to that file. If suppressStderr is true, logs won't be sent to the original handler (useful for TUI mode).
func Setup ¶
func Setup(logger *slog.Logger, program *tea.Program, logFilePath string, suppressStderr bool) (*Interceptor, error)
Setup configures the provided logger to intercept logs and send them to the TUI. If logFilePath is not empty, logs will also be written to that file. If suppressStderr is true, logs won't be sent to stderr (useful for TUI mode). Returns the interceptor (to be closed when done) and an error if setup fails.
func (*Interceptor) Close ¶
func (l *Interceptor) Close() error
Close closes the log file if one was opened.
func (*Interceptor) Enabled ¶
Enabled reports whether the handler handles records at the given level.
func (*Interceptor) FlushBuffer ¶
func (l *Interceptor) FlushBuffer()
FlushBuffer writes all buffered logs to the original handler (stderr). Call this after the TUI exits to show any logs that occurred during execution.
func (*Interceptor) Handle ¶
Handle processes a log record by sending it to the TUI and optionally writing to file.