log

package
v0.1.48 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package log provides centralized logging for the Tusk CLI.

Index

Constants

This section is empty.

Variables

View Source
var DeviationStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("208"))

DeviationStyle is orange for deviation messages

Functions

func Debug

func Debug(msg string, args ...any)

Debug logs a debug-level message

func Error

func Error(msg string, args ...any)

Error logs an error-level message

func Info

func Info(msg string, args ...any)

Info logs an info-level message

func Print

func Print(msg string)

Print prints a message without styling or newline

func Println

func Println(msg string)

Println prints a message with newline but no styling

func ServiceLog

func ServiceLog(msg string)

ServiceLog logs a message to the TUI service panel Non-blocking: returns immediately, message is queued for processing

func SetMode

func SetMode(mode OutputMode)

SetMode changes the output mode

func SetTUILogger

func SetTUILogger(tui TUILogger)

SetTUILogger sets the TUI logger (called when TUI starts)

func Setup

func Setup(debug bool, mode OutputMode)

Setup configures the singleton logger (call once at startup)

func Shutdown

func Shutdown()

Shutdown gracefully stops the logger, draining pending messages

func Stderr

func Stderr(msg string)

Stderr prints a message to stderr without newline

func Stderrln

func Stderrln(msg string)

Stderrln prints a message to stderr with newline

func TestLog

func TestLog(testID, msg string)

TestLog logs a message to a specific test's log panel Non-blocking: returns immediately, message is queued for processing

func TestOrServiceLog

func TestOrServiceLog(testID, msg string)

TestOrServiceLog tries to log to test, falls back to service if testID is empty

func UserDeviation

func UserDeviation(msg string)

UserDeviation prints a deviation/warning-level message (orange color)

func UserError

func UserError(msg string)

UserError prints a styled error message to the user

func UserInfo

func UserInfo(msg string)

UserInfo prints an informational message to the user

func UserProgress

func UserProgress(msg string)

UserProgress prints a progress/dim message to the user

func UserSuccess

func UserSuccess(msg string)

UserSuccess prints a styled success message to the user

func UserWarn

func UserWarn(msg string)

UserWarn prints a styled warning message to the user

func Warn

func Warn(msg string, args ...any)

Warn logs a warning-level message

Types

type Handler

type Handler struct {
	*slog.TextHandler
	// contains filtered or unexported fields
}

Handler wraps slog.TextHandler with mode-awareness

func NewHandler

func NewHandler(w io.Writer, opts *slog.HandlerOptions) *Handler

NewHandler creates a new mode-aware slog handler

func (*Handler) Handle

func (h *Handler) Handle(ctx context.Context, r slog.Record) error

Handle processes a log record

func (*Handler) WithAttrs

func (h *Handler) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs returns a new Handler with the given attributes

func (*Handler) WithGroup

func (h *Handler) WithGroup(name string) slog.Handler

WithGroup returns a new Handler with the given group

type Logger

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

func Get

func Get() *Logger

Get returns the singleton logger instance

type OutputMode

type OutputMode int

OutputMode determines how user-facing output is rendered

const (
	// ModeTUI indicates the TUI is active - user output goes to TUI panels
	ModeTUI OutputMode = iota
	// ModeHeadless indicates headless/print mode - user output goes to stdout
	ModeHeadless
)

func GetMode

func GetMode() OutputMode

GetMode returns the current output mode

type TUILogger

type TUILogger interface {
	LogToCurrentTest(testID, message string)
	LogToService(message string)
}

TUILogger interface for logging to TUI panels

Jump to

Keyboard shortcuts

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