log

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package log provides context-aware logging for wt.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithLogger

func WithLogger(ctx context.Context, l *Logger) context.Context

WithLogger attaches a logger to the context.

Types

type Logger

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

Logger provides output and verbose command logging.

func FromContext

func FromContext(ctx context.Context) *Logger

FromContext retrieves the logger from context. Returns a no-op logger if none is attached.

func New

func New(out io.Writer, verbose, quiet bool) *Logger

New creates a new logger.

func (*Logger) Command

func (l *Logger) Command(dir, name string, args ...string) func(time.Duration)

Command returns a function that logs an external command execution with duration. Call the returned function after the command completes. Only prints when verbose mode is enabled and quiet mode is disabled. If dir is non-empty, it's shown as a prefix: [dir] $ cmd args (duration)

func (*Logger) Debug added in v0.13.0

func (l *Logger) Debug(msg string, keyvals ...any)

Debug logs a debug message with key-value pairs. Only prints when verbose mode is enabled and quiet mode is disabled.

func (*Logger) IsVerbose added in v0.19.1

func (l *Logger) IsVerbose() bool

IsVerbose returns true if the logger is in verbose mode (and not quiet).

func (*Logger) Printf

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

Printf writes formatted output.

func (*Logger) Println

func (l *Logger) Println(args ...any)

Println writes a line of output.

func (*Logger) Writer

func (l *Logger) Writer() io.Writer

Writer returns the underlying writer.

Jump to

Keyboard shortcuts

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