logger

package
v1.18.0 Latest Latest
Warning

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

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

Documentation

Overview

Package logger provides the component-prefixed debug output that the client, engine, source, and store layers write when debugging is enabled.

A Logger writes to the sink it was given and nowhere else. There is no package-level destination: every component takes a sink from whoever constructed it, so two clients in one process can log to different places, or one can log while the other stays silent. A nil *Logger, and a logger bound to a nil writer, both discard — which lets a caller with no sink to offer pass one through unconditionally instead of branching (RFC 0022 §8).

Index

Constants

View Source
const (
	ColorBold   = "\033[1m"
	ColorDim    = "\033[2m"
	ColorRed    = "\033[31m"
	ColorGreen  = "\033[32m"
	ColorYellow = "\033[33m"
	ColorCyan   = "\033[36m"
	ColorReset  = "\033[0m"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

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

Logger allows component-specific prefixing for debug messages.

func New

func New(component, color string) *Logger

New returns a Logger with the specified component name and color, and no sink — it discards until one is bound with To.

Use it for a package-level default that declares a component's prefix and colour once, then bind a sink with To at each construction site.

func (*Logger) Debugf

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

Debugf formats and prints a debug message to this logger's sink, discarding it if the logger has none.

func (*Logger) To added in v1.18.0

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

To returns a copy of l that writes to w, keeping its prefix.

A nil w yields a discarding logger, so a caller that has no sink to offer can pass one through unconditionally instead of branching.

Jump to

Keyboard shortcuts

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