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
- func DebugEnabled(l ILogger) bool
- type DebugEnabler
- type ILogger
- type Noop
- func (Noop) Debug(...any)
- func (Noop) Debugf(string, ...any)
- func (Noop) Debugw(string, ...any)
- func (Noop) Error(...any)
- func (Noop) Errorw(string, error, ...any)
- func (Noop) Info(...any)
- func (Noop) Infof(string, ...any)
- func (Noop) Infow(string, ...any)
- func (Noop) NewLogger(string) logging.LeveledLogger
- func (Noop) Println(...any)
- func (Noop) Warn(...any)
- func (Noop) Warnf(string, ...any)
- func (Noop) Warnw(string, error, ...any)
- func (n Noop) WithField(string, any) ILogger
- func (n Noop) WithFields(map[string]any) ILogger
- func (n Noop) WithValues(...any) ILogger
- type NoopLeveled
- func (NoopLeveled) Debug(string)
- func (NoopLeveled) Debugf(string, ...any)
- func (NoopLeveled) Error(string)
- func (NoopLeveled) Errorf(string, ...any)
- func (NoopLeveled) Info(string)
- func (NoopLeveled) Infof(string, ...any)
- func (NoopLeveled) Trace(string)
- func (NoopLeveled) Tracef(string, ...any)
- func (NoopLeveled) Warn(string)
- func (NoopLeveled) Warnf(string, ...any)
Constants ¶
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 ¶
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) WithValues ¶
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)