contract

package
v1.19.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const LoggingConfigurationName = "logging"

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context map[string]any

type Level

type Level string
const (
	LevelUnknown Level = "unknown"

	LevelDebug     Level = "debug"
	LevelInfo      Level = "info"
	LevelWarning   Level = "warning"
	LevelError     Level = "error"
	LevelEmergency Level = "emergency"
)

type LevelLabel added in v1.8.0

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

func LevelLabelFromInt added in v1.8.0

func LevelLabelFromInt(i int) LevelLabel

func LevelLabelFromString added in v1.8.0

func LevelLabelFromString(s string) LevelLabel

func (LevelLabel) MarshalJSON added in v1.8.1

func (instance LevelLabel) MarshalJSON() ([]byte, error)

func (LevelLabel) String added in v1.8.0

func (instance LevelLabel) String() string

type LevelLabels added in v1.8.0

type LevelLabels map[Level]LevelLabel

func DefaultLevelLabels added in v1.8.0

func DefaultLevelLabels() LevelLabels

func (LevelLabels) LabelFor added in v1.8.0

func (instance LevelLabels) LabelFor(level Level) LevelLabel

type LevelReporter added in v1.19.0

type LevelReporter interface {
	Enabled(level Level) bool
}
LevelReporter is the optional capability a Logger implements to say, before being handed anything, whether a record at a given level would survive its threshold. It exists for the callers that BUILD what they log: the event dispatcher assembles a context map per dispatch and resolves a listener's name through reflection per listener per dispatch, and every one of those was discarded unread by a journal at error level, on the hottest path the framework has.

It stays beside Logger rather than inside it because a logger is the most implemented contract melody has — a test double, an integrator's adapter to their own journal — and a method added to Logger would refuse each of them at compilation for a capability that is an optimization. A logger that does not implement this is asked nothing and keeps answering every call, so the answer to an absent LevelReporter is always "enabled": the reporting behaviour is the floor, never the thing the capability turns off.

Enabled answers for the LEVEL alone. It is not permission to skip work whose absence changes what is recorded — a caller that computes a value the record needs must still compute it when the answer is false and something else reads it.

type Logger

type Logger interface {
	Log(level Level, message string, context Context)

	Debug(message string, context Context)

	Info(message string, context Context)

	Warning(message string, context Context)

	Error(message string, context Context)

	Emergency(message string, context Context)
}

type LoggingConfiguration added in v1.8.0

type LoggingConfiguration interface {
	LevelLabels() LevelLabels
}

Jump to

Keyboard shortcuts

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