logger

package
v2.1.9 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package logger provides logging functionality for the yap application.

Index

Constants

This section is empty.

Variables

View Source
var (
	// MultiPrinter is the default multiprinter for concurrent logging.
	MultiPrinter = &MultiPrinterImpl{Writer: os.Stderr}

	// Logger is the global YapLogger instance.
	Logger = &YapLogger{}
)
View Source
var KeyColorMap = map[string]func(string) string{

	"package":        color.Green,
	"distro":         color.Green,
	"release":        color.Green,
	"pkgver":         color.Green,
	"pkgrel":         color.Green,
	"source":         color.Green,
	"total_packages": color.Green,
	"total_batches":  color.Green,
	"count":          color.Green,

	"batch_number":     color.Blue,
	"batch_size":       color.Blue,
	"packages":         color.Blue,
	"parallel_workers": color.Blue,
	"progress":         color.Blue,
	"duration":         color.Blue,
	"timestamp":        color.Blue,

	"path":    color.HiBlue,
	"command": color.HiBlue,
	"dir":     color.HiBlue,
	"args":    color.HiBlue,

	"name":      color.Cyan,
	"success":   color.Cyan,
	"operation": color.Cyan,
}

KeyColorMap defines the color for each known key category.

Functions

func Debug

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

Debug logs a debug message using the global logger.

func Error

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

Error logs an error message using the global logger.

func Fatal

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

Fatal logs a fatal message using the global logger and exits.

func Info

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

Info logs an informational message using the global logger.

func IsColorDisabled

func IsColorDisabled() bool

IsColorDisabled checks if color output is disabled.

func IsVerboseEnabled

func IsVerboseEnabled() bool

IsVerboseEnabled returns true if verbose logging is enabled.

func SetColorDisabled

func SetColorDisabled(disabled bool)

SetColorDisabled enables or disables color output.

func SetVerbose

func SetVerbose(verbose bool)

SetVerbose configures the logger verbosity level.

func SetWriter

func SetWriter(w io.Writer)

SetWriter redirects the underlying logger's output to the given writer. Not goroutine-safe; call before spinning up any concurrent loggers.

func Tips

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

Tips logs a tip message using the global logger.

func Warn

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

Warn logs a warning message using the global logger.

Types

type CustomHandler

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

CustomHandler implements slog.Handler for yap's custom log format.

func (*CustomHandler) Enabled

func (h *CustomHandler) Enabled(_ context.Context, level slog.Level) bool

Enabled reports whether the handler handles records at the given level.

func (*CustomHandler) Handle

func (h *CustomHandler) Handle(_ context.Context, record slog.Record) error

Handle formats and writes a log record.

When all key-value pairs fit on one line within the terminal width they are appended inline. When the line would overflow, each pair is rendered on its own indented line with tree connectors (├ / └).

func (*CustomHandler) WithAttrs

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

WithAttrs returns a new handler with the given attributes (no-op for simplicity).

func (*CustomHandler) WithGroup

func (h *CustomHandler) WithGroup(_ string) slog.Handler

WithGroup returns a new handler with the given group (no-op for simplicity).

type MultiPrinterImpl

type MultiPrinterImpl struct {
	Writer io.Writer
	// contains filtered or unexported fields
}

MultiPrinterImpl provides concurrent-safe output handling. Writer is the destination for all log output; Start is a no-op kept for API compatibility with pkg/shell/exec.go.

func (*MultiPrinterImpl) Start

func (m *MultiPrinterImpl) Start() (io.Writer, error)

Start returns the writer for concurrent output (no-op; kept for API compat).

type YapLogger

type YapLogger struct{}

YapLogger provides yap-specific logging functionality.

func (*YapLogger) Debug

func (y *YapLogger) Debug(msg string, args ...any)

Debug logs a debug message (no-op unless verbose is enabled).

func (*YapLogger) Error

func (y *YapLogger) Error(msg string, args ...any)

Error logs an error message.

func (*YapLogger) Fatal

func (y *YapLogger) Fatal(msg string, args ...any)

Fatal logs a fatal message and exits with code 1.

func (*YapLogger) Info

func (y *YapLogger) Info(msg string, args ...any)

Info logs an informational message.

func (*YapLogger) Tips

func (y *YapLogger) Tips(msg string, _ ...any)

Tips logs a tip message with TIPS prefix.

func (*YapLogger) Warn

func (y *YapLogger) Warn(msg string, args ...any)

Warn logs a warning message.

Jump to

Keyboard shortcuts

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