logger

package
v0.0.0-...-f8853a5 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package logger defines the logging interface used throughout this module.

There is deliberately no package-level default logger and no global state: every component takes an ILogger through its options and falls back to Noop when none is supplied. Applications that want output pass an adapter, e.g. logger.FromLogrus(logrus.StandardLogger()).

Index

Constants

View Source
const (
	DtlsState     = "dtls_state"
	NegotiationId = "negotiation_id"
)

Field names used in structured log records. Using constants keeps the field names consistent across packages.

Variables

This section is empty.

Functions

func DebugEnabled

func DebugEnabled(l ILogger) bool

DebugEnabled reports whether l emits debug records. Loggers that do not implement DebugEnabler are assumed not to.

Types

type DebugEnabler

type DebugEnabler interface {
	DebugEnabled() bool
}

DebugEnabler is implemented by loggers that can report whether debug output would be emitted, letting callers skip expensive message construction.

type ILogger

type ILogger interface {
	Debug(args ...any)
	Info(args ...any)
	Warn(args ...any)
	Error(args ...any)
	Println(args ...any)

	Debugf(format string, args ...any)
	Infof(format string, args ...any)
	Warnf(format string, args ...any)

	Debugw(msg string, keysAndValues ...any)
	Infow(msg string, keysAndValues ...any)
	// Warnw and Errorw take the error explicitly so adapters can attach it
	// under a dedicated field; err may be nil.
	Warnw(msg string, err error, keysAndValues ...any)
	Errorw(msg string, err error, keysAndValues ...any)

	WithField(key string, value any) ILogger
	WithFields(fields map[string]any) ILogger
	WithValues(keysAndValues ...any) ILogger

	// NewLogger returns a pion-compatible logger for the given scope, so the
	// SDK can hand pion/webrtc a logger factory backed by the same sink.
	NewLogger(scope string) logging.LeveledLogger
}

ILogger is the logging surface the SDK depends on. It is a superset of the two styles the code uses: printf/field-style calls (Info, Warnf, WithField) in the call and signalling layers, and structured key/value calls (Infow, Warnw) in the peer-connection layer.

func FromLogrus

func FromLogrus(l logrus.FieldLogger) ILogger

FromLogrus adapts any logrus logger or entry to ILogger.

type Noop

type Noop struct{}

Noop is an ILogger that discards everything. It is the default for every component that accepts a logger.

func (Noop) Debug

func (Noop) Debug(...any)

func (Noop) Debugf

func (Noop) Debugf(string, ...any)

func (Noop) Debugw

func (Noop) Debugw(string, ...any)

func (Noop) Error

func (Noop) Error(...any)

func (Noop) Errorw

func (Noop) Errorw(string, error, ...any)

func (Noop) Info

func (Noop) Info(...any)

func (Noop) Infof

func (Noop) Infof(string, ...any)

func (Noop) Infow

func (Noop) Infow(string, ...any)

func (Noop) NewLogger

func (Noop) NewLogger(string) logging.LeveledLogger

func (Noop) Println

func (Noop) Println(...any)

func (Noop) Warn

func (Noop) Warn(...any)

func (Noop) Warnf

func (Noop) Warnf(string, ...any)

func (Noop) Warnw

func (Noop) Warnw(string, error, ...any)

func (Noop) WithField

func (n Noop) WithField(string, any) ILogger

func (Noop) WithFields

func (n Noop) WithFields(map[string]any) ILogger

func (Noop) WithValues

func (n Noop) WithValues(...any) ILogger

type NoopLeveled

type NoopLeveled struct{}

NoopLeveled is a pion logging.LeveledLogger that discards everything.

func (NoopLeveled) Debug

func (NoopLeveled) Debug(string)

func (NoopLeveled) Debugf

func (NoopLeveled) Debugf(string, ...any)

func (NoopLeveled) Error

func (NoopLeveled) Error(string)

func (NoopLeveled) Errorf

func (NoopLeveled) Errorf(string, ...any)

func (NoopLeveled) Info

func (NoopLeveled) Info(string)

func (NoopLeveled) Infof

func (NoopLeveled) Infof(string, ...any)

func (NoopLeveled) Trace

func (NoopLeveled) Trace(string)

func (NoopLeveled) Tracef

func (NoopLeveled) Tracef(string, ...any)

func (NoopLeveled) Warn

func (NoopLeveled) Warn(string)

func (NoopLeveled) Warnf

func (NoopLeveled) Warnf(string, ...any)

Jump to

Keyboard shortcuts

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