logging

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package logging is instigator's leveled, printf-style log output: one line per record - an RFC3339 timestamp, the level (DEBUG/INFO/WARN/ERROR), then the formatted message. A nil *Logger is a silent no-op, so an unset logger costs nothing and every call site can stay unconditional.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level int

Level is a log severity; the four constants are the only levels instigator uses, ordered least to most severe.

const (
	LevelDebug Level = iota // per-packet/per-block decode detail, -v only
	LevelInfo               // normal serving: requests answered, transfers made
	LevelWarn               // a request refused or malformed on the client's end
	LevelError              // this side failed to do something it should have
)

func (Level) String added in v0.2.1

func (l Level) String() string

type Logger

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

Logger writes leveled, printf-style lines to one destination. A nil *Logger is safe to call - every method is a no-op - matching the unset-means-silent convention callers and tests rely on.

func New

func New(w io.Writer, min Level) *Logger

New builds a Logger writing to w. min is the lowest level written; records below it cost only a level comparison, since the level methods check Enabled before formatting their arguments.

func (*Logger) Debugf

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

func (*Logger) Enabled

func (l *Logger) Enabled(level Level) bool

Enabled reports whether a message at level would be written. A hot path that builds expensive-to-format arguments should check this before doing that work, rather than relying on the level method to discard the message after.

func (*Logger) Errorf

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

func (*Logger) Infof

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

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