logging

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: GPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DBRelativePathLabel added in v0.2.3

func DBRelativePathLabel(value string) (string, bool)

DBRelativePathLabel returns a slash-normalized .upbrr tmp/cache/log suffix when value is inside a known app DB subdirectory. The boolean is false for ordinary local paths that should be replaced with a generic label.

func LogPath

func LogPath(dbPath string) (string, error)

func ResolveEffectiveLevel

func ResolveEffectiveLevel(configured string, runOverride string, debug bool) string

func SanitizeMessage added in v0.2.3

func SanitizeMessage(message string) string

SanitizeMessage replaces local filesystem paths in user-shareable log or terminal output with stable labels. Paths under known app DB tmp/cache/log directories keep only their .upbrr-relative suffix; other local paths become [local path].

func SetDefaultConsoleOutput added in v0.2.1

func SetDefaultConsoleOutput(stdout io.Writer, stderr io.Writer) func()

SetDefaultConsoleOutput replaces the console writers used by new loggers and returns a restore function. Nil writers leave the corresponding output unchanged.

Types

type Entry

type Entry struct {
	ID      int64     `json:"id"`
	Time    time.Time `json:"time" ts_type:"string"`
	Level   string    `json:"level"`
	Message string    `json:"message"`
}

type Level

type Level int
const (
	LevelError Level = iota
	LevelWarn
	LevelInfo
	LevelDebug
	LevelTrace
)

func ParseLevel

func ParseLevel(value string) (Level, error)

func (Level) String

func (l Level) String() string

type Logger

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

func New

func New(cfg config.LoggingConfig, dbPath string) (*Logger, error)

func NewWithLevel

func NewWithLevel(cfg config.LoggingConfig, dbPath string, override string) (*Logger, error)

func (*Logger) Close

func (l *Logger) Close() error

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...any)

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...any)

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...any)

func (*Logger) Recent

func (l *Logger) Recent(limit int) []Entry

func (*Logger) SetConsoleOutput added in v0.2.1

func (l *Logger) SetConsoleOutput(stdout io.Writer, stderr io.Writer)

SetConsoleOutput replaces the console writers used for stdout and stderr logging. Nil writers leave the corresponding output unchanged.

func (*Logger) Subscribe

func (l *Logger) Subscribe(buffer int) (int, <-chan Entry)

func (*Logger) Tracef

func (l *Logger) Tracef(format string, args ...any)

func (*Logger) Unsubscribe

func (l *Logger) Unsubscribe(id int)

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...any)

Jump to

Keyboard shortcuts

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