logger

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
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
)

Variables

This section is empty.

Functions

func Fatalf

func Fatalf(logger Logger, format string, v ...interface{})

Fatalf logs an error and exits the program

func GetTerminalSize

func GetTerminalSize() (width, height int)

GetTerminalSize returns the current terminal size Returns default 80x24 if detection fails

func IsTUISupported

func IsTUISupported() bool

IsTUISupported checks if the terminal supports TUI mode Returns true if terminal is detected, supports ANSI codes, and meets minimum size requirements

Types

type AnimationFrames

type AnimationFrames struct {
	// contains filtered or unexported fields
}

AnimationFrames manages animation frames for the mooncake character

func LoadEmbeddedFrames

func LoadEmbeddedFrames() (*AnimationFrames, error)

LoadEmbeddedFrames loads animation frames from the embedded content

func LoadFramesFromFile

func LoadFramesFromFile(path string) (*AnimationFrames, error)

LoadFramesFromFile loads animation frames from a file Frames are expected to be 3 lines each, separated by blank lines

func LoadFramesFromString

func LoadFramesFromString(content string) (*AnimationFrames, error)

LoadFramesFromString loads animation frames from a string Frames are expected to be 3 lines each, separated by blank lines

func (*AnimationFrames) Current

func (a *AnimationFrames) Current() []string

Current returns the current frame without advancing

func (*AnimationFrames) FrameCount

func (a *AnimationFrames) FrameCount() int

FrameCount returns the total number of frames

func (*AnimationFrames) Next

func (a *AnimationFrames) Next() []string

Next advances to the next frame and returns it

type BufferSnapshot

type BufferSnapshot struct {
	StepHistory   []StepEntry
	CurrentStep   string
	Progress      ProgressInfo
	DebugMessages []string
	ErrorMessages []string
}

BufferSnapshot is an atomic snapshot of the buffer state for rendering

type ConsoleLogger

type ConsoleLogger struct {
	// contains filtered or unexported fields
}

ConsoleLogger implements Logger interface with colored console output

func NewConsoleLogger

func NewConsoleLogger(logLevel int) *ConsoleLogger

NewConsoleLogger creates a ConsoleLogger directly (for type-specific needs)

func (*ConsoleLogger) Codef

func (l *ConsoleLogger) Codef(format string, v ...interface{})

func (*ConsoleLogger) Debugf

func (l *ConsoleLogger) Debugf(format string, v ...interface{})

func (*ConsoleLogger) Errorf

func (l *ConsoleLogger) Errorf(format string, v ...interface{})

func (*ConsoleLogger) Infof

func (l *ConsoleLogger) Infof(format string, v ...interface{})

func (*ConsoleLogger) Mooncake

func (l *ConsoleLogger) Mooncake()

func (*ConsoleLogger) SetLogLevel

func (l *ConsoleLogger) SetLogLevel(logLevel int)

func (*ConsoleLogger) SetLogLevelStr

func (l *ConsoleLogger) SetLogLevelStr(logLevel string) error

func (*ConsoleLogger) Textf

func (l *ConsoleLogger) Textf(format string, v ...interface{})

func (*ConsoleLogger) WithPadLevel

func (l *ConsoleLogger) WithPadLevel(padLevel int) Logger

type LogEntry

type LogEntry struct {
	Level   string
	Message string
}

LogEntry represents a single log entry

type Logger

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
}

Logger interface defines the logging contract

func NewLogger

func NewLogger(logLevel int) Logger

NewLogger creates a new ConsoleLogger with the specified log level

type ProgressInfo

type ProgressInfo struct {
	Current int
	Total   int
}

ProgressInfo tracks overall execution progress

type StepEntry

type StepEntry struct {
	Name      string
	Status    string // "success", "error", "skipped", "running"
	Level     int    // Nesting level for indentation
	Timestamp time.Time
}

StepEntry represents a single step in the execution history

type TUIBuffer

type TUIBuffer struct {
	// contains filtered or unexported fields
}

TUIBuffer manages step history and message buffering

func NewTUIBuffer

func NewTUIBuffer(historySize int) *TUIBuffer

NewTUIBuffer creates a new TUI buffer with specified history size

func (*TUIBuffer) AddDebug

func (b *TUIBuffer) AddDebug(message string)

AddDebug adds a debug message to the buffer

func (*TUIBuffer) AddError

func (b *TUIBuffer) AddError(message string)

AddError adds an error message to the buffer

func (*TUIBuffer) AddStep

func (b *TUIBuffer) AddStep(entry StepEntry)

AddStep adds a step to the history (circular buffer)

func (*TUIBuffer) GetSnapshot

func (b *TUIBuffer) GetSnapshot() BufferSnapshot

GetSnapshot returns an atomic snapshot of the buffer state

func (*TUIBuffer) SetCurrentStep

func (b *TUIBuffer) SetCurrentStep(name string, progress ProgressInfo)

SetCurrentStep sets the currently executing step

type TUIDisplay

type TUIDisplay struct {
	// contains filtered or unexported fields
}

TUIDisplay handles screen rendering for the animated TUI

func NewTUIDisplay

func NewTUIDisplay(animator *AnimationFrames, buffer *TUIBuffer, width, height int) *TUIDisplay

NewTUIDisplay creates a new TUI display renderer

func (*TUIDisplay) Render

func (d *TUIDisplay) Render() string

Render generates the complete screen output

type TUILogger

type TUILogger struct {
	// contains filtered or unexported fields
}

TUILogger implements Logger interface with animated TUI display

func NewTUILogger

func NewTUILogger(logLevel int) (*TUILogger, error)

NewTUILogger creates a new TUI logger

func (*TUILogger) Codef

func (l *TUILogger) Codef(format string, v ...interface{})

Codef logs formatted code

func (*TUILogger) Debugf

func (l *TUILogger) Debugf(format string, v ...interface{})

Debugf logs a debug message

func (*TUILogger) Errorf

func (l *TUILogger) Errorf(format string, v ...interface{})

Errorf logs an error message

func (*TUILogger) Infof

func (l *TUILogger) Infof(format string, v ...interface{})

Infof logs an info message and updates current step

func (*TUILogger) Mooncake

func (l *TUILogger) Mooncake()

Mooncake displays the mooncake banner (initializes display)

func (*TUILogger) SetLogLevel

func (l *TUILogger) SetLogLevel(logLevel int)

SetLogLevel sets the log level

func (*TUILogger) SetLogLevelStr

func (l *TUILogger) SetLogLevelStr(logLevel string) error

SetLogLevelStr sets the log level from a string

func (*TUILogger) Start

func (l *TUILogger) Start()

Start begins the animation and rendering loop

func (*TUILogger) Stop

func (l *TUILogger) Stop()

Stop stops the animation and shows final render

func (*TUILogger) Textf

func (l *TUILogger) Textf(format string, v ...interface{})

Textf logs plain text

func (*TUILogger) WithPadLevel

func (l *TUILogger) WithPadLevel(padLevel int) Logger

WithPadLevel creates a new logger with the specified padding level

type TerminalInfo

type TerminalInfo struct {
	IsTerminal   bool
	SupportsANSI bool
	Width        int
	Height       int
}

TerminalInfo contains information about terminal capabilities

func DetectTerminal

func DetectTerminal() TerminalInfo

DetectTerminal detects terminal capabilities and returns terminal information

type TestLogger

type TestLogger struct {
	Logs []LogEntry
	// contains filtered or unexported fields
}

TestLogger implements Logger interface and captures log output for testing

func NewTestLogger

func NewTestLogger() *TestLogger

NewTestLogger creates a new TestLogger for use in tests

func (*TestLogger) Clear

func (t *TestLogger) Clear()

Clear removes all log entries

func (*TestLogger) Codef

func (t *TestLogger) Codef(format string, v ...interface{})

func (*TestLogger) Contains

func (t *TestLogger) Contains(substr string) bool

Contains checks if any log message contains the substring

func (*TestLogger) ContainsLevel

func (t *TestLogger) ContainsLevel(level, substr string) bool

ContainsLevel checks if any log at the specified level contains the substring

func (*TestLogger) Count

func (t *TestLogger) Count() int

Count returns the number of log entries

func (*TestLogger) CountLevel

func (t *TestLogger) CountLevel(level string) int

CountLevel returns the number of log entries at the specified level

func (*TestLogger) Debugf

func (t *TestLogger) Debugf(format string, v ...interface{})

func (*TestLogger) Errorf

func (t *TestLogger) Errorf(format string, v ...interface{})

func (*TestLogger) GetLogs

func (t *TestLogger) GetLogs() []LogEntry

GetLogs returns a copy of all log entries

func (*TestLogger) Infof

func (t *TestLogger) Infof(format string, v ...interface{})

func (*TestLogger) Mooncake

func (t *TestLogger) Mooncake()

func (*TestLogger) SetLogLevel

func (t *TestLogger) SetLogLevel(logLevel int)

func (*TestLogger) SetLogLevelStr

func (t *TestLogger) SetLogLevelStr(logLevel string) error

func (*TestLogger) Textf

func (t *TestLogger) Textf(format string, v ...interface{})

func (*TestLogger) WithPadLevel

func (t *TestLogger) WithPadLevel(padLevel int) Logger

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL