logger¶
Package logger provides logging interfaces and implementations for mooncake.
Index¶
- Constants
- func Fatalf(logger Logger, format string, v ...interface{})
- func GetTerminalSize() (width, height int)
- func IsTUISupported() bool
- func ParseLogLevel(level string) (int, error)
- type AnimationFrames
- func LoadEmbeddedFrames() (*AnimationFrames, error)
- func LoadFramesFromFile(path string) (*AnimationFrames, error)
- func LoadFramesFromString(content string) (*AnimationFrames, error)
- func (a *AnimationFrames) Current() []string
- func (a *AnimationFrames) FrameCount() int
- func (a *AnimationFrames) Next() []string
- type BufferSnapshot
- type ConsoleLogger
- func NewConsoleLogger(logLevel int) *ConsoleLogger
- func (l *ConsoleLogger) Codef(format string, v ...interface{})
- func (l *ConsoleLogger) Complete(stats ExecutionStats)
- func (l *ConsoleLogger) Debugf(format string, v ...interface{})
- func (l *ConsoleLogger) Errorf(format string, v ...interface{})
- func (l *ConsoleLogger) Infof(format string, v ...interface{})
- func (l *ConsoleLogger) LogStep(info StepInfo)
- func (l *ConsoleLogger) Mooncake()
- func (l *ConsoleLogger) SetLogLevel(logLevel int)
- func (l *ConsoleLogger) SetLogLevelStr(logLevel string) error
- func (l *ConsoleLogger) SetRedactor(redactor Redactor)
- func (l *ConsoleLogger) Textf(format string, v ...interface{})
- func (l *ConsoleLogger) WithPadLevel(padLevel int) Logger
- type ConsoleSubscriber
- func NewConsoleSubscriber(logLevel int, logFormat string) *ConsoleSubscriber
- func (c *ConsoleSubscriber) Close()
- func (c *ConsoleSubscriber) OnEvent(event events.Event)
- func (c *ConsoleSubscriber) SetRedactor(r interface{ Redact(string) string })
- type ExecutionStats
- type LogEntry
- type Logger
- func NewLogger(logLevel int) Logger
- type ProgressInfo
- type Redactor
- type StepEntry
- type StepInfo
- type TUIBuffer
- func NewTUIBuffer(historySize int) *TUIBuffer
- func (b *TUIBuffer) AddDebug(message string)
- func (b *TUIBuffer) AddError(message string)
- func (b *TUIBuffer) AddStep(entry StepEntry)
- func (b *TUIBuffer) GetSnapshot() BufferSnapshot
- func (b *TUIBuffer) SetCompletion(stats ExecutionStats)
- func (b *TUIBuffer) SetCurrentStep(name string, progress ProgressInfo)
- type TUIDisplay
- func NewTUIDisplay(animator *AnimationFrames, buffer *TUIBuffer, width, height int) *TUIDisplay
- func (d *TUIDisplay) Render() string
- type TUILogger
- func NewTUILogger(logLevel int) (*TUILogger, error)
- func (l *TUILogger) Codef(format string, v ...interface{})
- func (l *TUILogger) Complete(stats ExecutionStats)
- func (l *TUILogger) Debugf(format string, v ...interface{})
- func (l *TUILogger) Errorf(format string, v ...interface{})
- func (l *TUILogger) Infof(_ string, _ ...interface{})
- func (l *TUILogger) LogStep(info StepInfo)
- func (l *TUILogger) Mooncake()
- func (l *TUILogger) SetLogLevel(logLevel int)
- func (l *TUILogger) SetLogLevelStr(logLevel string) error
- func (l *TUILogger) SetRedactor(redactor Redactor)
- func (l *TUILogger) Start()
- func (l *TUILogger) Stop()
- func (l *TUILogger) Textf(format string, v ...interface{})
- func (l *TUILogger) WithPadLevel(padLevel int) Logger
- type TUISubscriber
- func NewTUISubscriber(logLevel int) (*TUISubscriber, error)
- func (t *TUISubscriber) Close()
- func (t *TUISubscriber) OnEvent(event events.Event)
- func (t *TUISubscriber) SetRedactor(r Redactor)
- func (t *TUISubscriber) Start()
- func (t *TUISubscriber) Stop()
- type TerminalInfo
- func DetectTerminal() TerminalInfo
- type TestLogger
- func NewTestLogger() *TestLogger
- func (t *TestLogger) Clear()
- func (t *TestLogger) Codef(format string, v ...interface{})
- func (t *TestLogger) Complete(stats ExecutionStats)
- func (t *TestLogger) Contains(substr string) bool
- func (t *TestLogger) ContainsLevel(level, substr string) bool
- func (t *TestLogger) Count() int
- func (t *TestLogger) CountLevel(level string) int
- func (t *TestLogger) Debugf(format string, v ...interface{})
- func (t *TestLogger) Errorf(format string, v ...interface{})
- func (t *TestLogger) GetLogs() []LogEntry
- func (t *TestLogger) Infof(format string, v ...interface{})
- func (t *TestLogger) LogStep(info StepInfo)
- func (t *TestLogger) Mooncake()
- func (t *TestLogger) SetLogLevel(logLevel int)
- func (t *TestLogger) SetLogLevelStr(logLevel string) error
- func (t *TestLogger) SetRedactor(redactor Redactor)
- func (t *TestLogger) Textf(format string, v ...interface{})
- func (t *TestLogger) WithPadLevel(padLevel int) Logger
Constants¶
const (
// DebugLevel logs are typically voluminous, and are usually disabled in
// production.
DebugLevel = iota
// InfoLevel is the default logging priority.
InfoLevel
// ErrorLevel logs are high-priority. If an application is running smoothly,
// it shouldn't generate any error-logLevel logs.
ErrorLevel
)
Step status constants used across all logger implementations
const (
StatusRunning = "running"
StatusSuccess = "success"
StatusError = "error"
StatusSkipped = "skipped"
)
func Fatalf¶
Fatalf logs an error and exits the program.
func GetTerminalSize¶
GetTerminalSize returns the current terminal size. Returns default 80x24 if detection fails.
func IsTUISupported¶
IsTUISupported checks if the terminal supports TUI mode. Returns true if terminal is detected, supports ANSI codes, and meets minimum size requirements.
func ParseLogLevel¶
ParseLogLevel converts a log level string to its integer constant. Valid values are "debug", "info", and "error" (case-insensitive). Returns an error if the level string is not recognized.
type AnimationFrames¶
AnimationFrames manages animation frames for the mooncake character.
func LoadEmbeddedFrames¶
LoadEmbeddedFrames loads animation frames from the embedded content.
func LoadFramesFromFile¶
LoadFramesFromFile loads animation frames from a file. Frames are expected to be 3 lines each, separated by blank lines.
func LoadFramesFromString¶
LoadFramesFromString loads animation frames from a string. Frames are expected to be 3 lines each, separated by blank lines.
func (*AnimationFrames) Current¶
Current returns the current frame without advancing
func (*AnimationFrames) FrameCount¶
FrameCount returns the total number of frames
func (*AnimationFrames) Next¶
Next advances to the next frame and returns it
type BufferSnapshot¶
BufferSnapshot is an atomic snapshot of the buffer state for rendering.
type BufferSnapshot struct {
StepHistory []StepEntry
CurrentStep string
Progress ProgressInfo
DebugMessages []string
ErrorMessages []string
Completion *ExecutionStats
}
type ConsoleLogger¶
ConsoleLogger implements Logger interface with colored console output.
func NewConsoleLogger¶
NewConsoleLogger creates a ConsoleLogger directly (for type-specific needs).
func (*ConsoleLogger) Codef¶
Codef logs a code snippet message.
func (*ConsoleLogger) Complete¶
Complete logs the execution completion summary with statistics.
func (*ConsoleLogger) Debugf¶
Debugf logs a debug message.
func (*ConsoleLogger) Errorf¶
Errorf logs an error message.
func (*ConsoleLogger) Infof¶
Infof logs an informational message.
func (*ConsoleLogger) LogStep¶
LogStep logs a step execution with status.
func (*ConsoleLogger) Mooncake¶
Mooncake displays the mooncake banner.
func (*ConsoleLogger) SetLogLevel¶
SetLogLevel sets the logging level for the logger.
func (*ConsoleLogger) SetLogLevelStr¶
SetLogLevelStr sets the logging level from a string value.
func (*ConsoleLogger) SetRedactor¶
SetRedactor sets the redactor for automatic sensitive data redaction.
func (*ConsoleLogger) Textf¶
Textf logs a plain text message.
func (*ConsoleLogger) WithPadLevel¶
WithPadLevel creates a new logger with the specified padding level.
type ConsoleSubscriber¶
ConsoleSubscriber implements event-based console logging
func NewConsoleSubscriber¶
NewConsoleSubscriber creates a new console subscriber
func (*ConsoleSubscriber) Close¶
Close implements the Subscriber interface
func (*ConsoleSubscriber) OnEvent¶
OnEvent handles incoming events
func (*ConsoleSubscriber) SetRedactor¶
SetRedactor sets the redactor for sensitive data
type ExecutionStats¶
ExecutionStats contains execution statistics.
type LogEntry¶
LogEntry represents a single log entry.
type Logger¶
Logger interface defines the logging contract.
type Logger interface {
Infof(format string, v ...interface{})
Debugf(format string, v ...interface{})
Errorf(format string, v ...interface{})
Codef(format string, v ...interface{})
Textf(format string, v ...interface{})
Mooncake()
SetLogLevel(logLevel int)
SetLogLevelStr(logLevel string) error
WithPadLevel(padLevel int) Logger
LogStep(info StepInfo)
Complete(stats ExecutionStats)
SetRedactor(redactor Redactor)
}
func NewLogger¶
NewLogger creates a new ConsoleLogger with the specified log level.
type ProgressInfo¶
ProgressInfo tracks overall execution progress.
type Redactor¶
Redactor interface for redacting sensitive data in logs.
type StepEntry¶
StepEntry represents a single step in the execution history.
type StepEntry struct {
Name string
Status string // "success", "error", "skipped", "running"
Level int // Nesting level for indentation
Timestamp time.Time
}
type StepInfo¶
StepInfo contains structured information about a step execution.
type StepInfo struct {
Name string
Level int // Nesting level for indentation
GlobalStep int // Cumulative step number
Status string // "running", "success", "error", "skipped"
}
type TUIBuffer¶
TUIBuffer manages step history and message buffering.
func NewTUIBuffer¶
NewTUIBuffer creates a new TUI buffer with specified history size.
func (*TUIBuffer) AddDebug¶
AddDebug adds a debug message to the buffer.
func (*TUIBuffer) AddError¶
AddError adds an error message to the buffer.
func (*TUIBuffer) AddStep¶
AddStep adds a step to the history (circular buffer).
func (*TUIBuffer) GetSnapshot¶
GetSnapshot returns an atomic snapshot of the buffer state.
func (*TUIBuffer) SetCompletion¶
SetCompletion sets execution completion statistics.
func (*TUIBuffer) SetCurrentStep¶
SetCurrentStep sets the currently executing step.
type TUIDisplay¶
TUIDisplay handles screen rendering for the animated TUI.
func NewTUIDisplay¶
NewTUIDisplay creates a new TUI display renderer.
func (*TUIDisplay) Render¶
Render generates the complete screen output.
type TUILogger¶
TUILogger implements Logger interface with animated TUI display.
func NewTUILogger¶
NewTUILogger creates a new TUI logger.
func (*TUILogger) Codef¶
Codef logs formatted code.
func (*TUILogger) Complete¶
Complete logs the execution completion summary with statistics.
func (*TUILogger) Debugf¶
Debugf logs a debug message.
func (*TUILogger) Errorf¶
Errorf logs an error message.
func (*TUILogger) Infof¶
Infof logs an info message (ignored in TUI mode - use LogStep for steps).
func (*TUILogger) LogStep¶
LogStep handles structured step logging.
func (*TUILogger) Mooncake¶
Mooncake displays the mooncake banner (initializes display).
func (*TUILogger) SetLogLevel¶
SetLogLevel sets the log level.
func (*TUILogger) SetLogLevelStr¶
SetLogLevelStr sets the log level from a string.
func (*TUILogger) SetRedactor¶
SetRedactor sets the redactor for automatic sensitive data redaction.
func (*TUILogger) Start¶
Start begins the animation and rendering loop.
func (*TUILogger) Stop¶
Stop stops the animation and shows final render.
func (*TUILogger) Textf¶
Textf logs plain text.
func (*TUILogger) WithPadLevel¶
WithPadLevel creates a new logger with the specified padding level.
type TUISubscriber¶
TUISubscriber implements event-based TUI display.
func NewTUISubscriber¶
NewTUISubscriber creates a new TUI subscriber.
func (*TUISubscriber) Close¶
Close implements the Subscriber interface.
func (*TUISubscriber) OnEvent¶
OnEvent handles incoming events.
func (*TUISubscriber) SetRedactor¶
SetRedactor sets the redactor for sensitive data.
func (*TUISubscriber) Start¶
Start begins the animation and rendering loop.
func (*TUISubscriber) Stop¶
Stop stops the animation and shows final render.
type TerminalInfo¶
TerminalInfo contains information about terminal capabilities.
func DetectTerminal¶
DetectTerminal detects terminal capabilities and returns terminal information.
type TestLogger¶
TestLogger implements Logger interface and captures log output for testing.
func NewTestLogger¶
NewTestLogger creates a new TestLogger for use in tests.
func (*TestLogger) Clear¶
Clear removes all log entries.
func (*TestLogger) Codef¶
Codef logs a code snippet message.
func (*TestLogger) Complete¶
Complete logs the execution completion summary with statistics.
func (*TestLogger) Contains¶
Contains checks if any log message contains the substring.
func (*TestLogger) ContainsLevel¶
ContainsLevel checks if any log at the specified level contains the substring.
func (*TestLogger) Count¶
Count returns the number of log entries.
func (*TestLogger) CountLevel¶
CountLevel returns the number of log entries at the specified level.
func (*TestLogger) Debugf¶
Debugf logs a debug message.
func (*TestLogger) Errorf¶
Errorf logs an error message.
func (*TestLogger) GetLogs¶
GetLogs returns a copy of all log entries.
func (*TestLogger) Infof¶
Infof logs an informational message.
func (*TestLogger) LogStep¶
LogStep logs a step execution with status.
func (*TestLogger) Mooncake¶
Mooncake displays the mooncake banner.
func (*TestLogger) SetLogLevel¶
SetLogLevel sets the logging level for the logger.
func (*TestLogger) SetLogLevelStr¶
SetLogLevelStr sets the logging level from a string value.
func (*TestLogger) SetRedactor¶
SetRedactor sets the redactor for automatic sensitive data redaction.
func (*TestLogger) Textf¶
Textf logs a plain text message.
func (*TestLogger) WithPadLevel¶
WithPadLevel creates a new logger with the specified padding level.
Generated by gomarkdoc