log

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package log writes notable application events to ~/.config/perk-workbench/event.log. File-based — survives TUI restart, no truncation in a single-line footer. Entries below the configured level (SetLevel, built-in default Info) are dropped before reaching the file or the notifier. Safe for concurrent calls (async Bubble Tea commands).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string)

Debug writes a timestamped debug entry. Silent on failure (best-effort).

func Error

func Error(op string, err error)

Error writes a timestamped error entry with an operation context. Silent on failure (best-effort); a nil error is a no-op.

func Info

func Info(msg string)

Info writes a timestamped info entry. Silent on failure (best-effort).

func Printf

func Printf(format string, args ...any)

Printf writes a timestamped info entry. Silent on failure (best-effort).

func SetLevel

func SetLevel(level Level)

SetLevel configures the minimum severity written to the event log and delivered to the notifier. Entries below the level are dropped entirely. The built-in default is Info; config.json "log_level" sets it at startup.

func SetNotifier

func SetNotifier(fn func(Entry))

SetNotifier registers a callback invoked after each entry is written to the log file. The callback runs synchronously in the caller's goroutine, so it must be fast and must not itself call into this package. A nil callback disables notifications.

func Warn

func Warn(msg string)

Warn writes a timestamped warning entry. Silent on failure (best-effort).

Types

type Entry

type Entry struct {
	Time    time.Time
	Level   Level
	Message string
}

Entry is one logged event. Time is the instant the entry was created.

type Level

type Level uint8

Level is the severity of a log entry, ordered from least to most severe.

const (
	LevelDebug Level = iota
	LevelInfo
	LevelWarn
	LevelError
)

func (Level) String

func (l Level) String() string

String returns the uppercase kind written to the log file.

func (Level) Title

func (l Level) Title() string

Title returns the display name used in notifications.

Jump to

Keyboard shortcuts

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