logger

package
v2.0.0-...-e2807f6 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package logger provides contextual log features for Ion using slog interface and zap backend.

Index

Constants

View Source
const (
	LevelTrace = slog.Level(-8)
)

Variables

This section is empty.

Functions

func BuildEncoder

func BuildEncoder(format config.LogFormat) (zapcore.Encoder, error)

BuildEncoder parses and builds a Zap encoder.

func BuildWriteSyncer

func BuildWriteSyncer(writer config.WriterType) (zapcore.WriteSyncer, error)

BuildWriteSyncer parses and build a Zap WriteSyncer.

func ParseZapLevel

func ParseZapLevel(level string) zapcore.Level

ParseZapLevel parses level from string to zapcore.Levels.

func WithContext

func WithContext(ctx context.Context, l *slog.Logger) context.Context

WithContext stores a logger in context and return copy of the context.

Types

type LoggerFactory

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

func NewLoggerFactory

func NewLoggerFactory(opts Options) (*LoggerFactory, error)

NewLoggerFactory creates a new LoggerFactory.

func (*LoggerFactory) BuildLoggerForCtx

func (f *LoggerFactory) BuildLoggerForCtx(ctx context.Context, scope string) context.Context

BuildLoggerForCtx creates a logger and bind it with ctx appending with scope key value pair.

func (*LoggerFactory) FromCtx

func (f *LoggerFactory) FromCtx(ctx context.Context) *slog.Logger

FromCtx returns the logger stored in ctx or the factory root logger.

func (*LoggerFactory) NewPionAdaptor

func (f *LoggerFactory) NewPionAdaptor(ctx context.Context) *PionAdaptorFactory

NewPionAdaptor generates a PionAdaptorFactory that can be passed into a webrtc api. The webrtc api will generate logger using this factory with context ctx.

type Options

type Options struct {
	TestWriter    io.Writer
	ScopeLevels   map[string]string
	DefaultLevel  string
	Format        config.LogFormat
	DefaultWriter config.WriterType
}

type PionAdaptorFactory

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

func (*PionAdaptorFactory) NewLogger

func (f *PionAdaptorFactory) NewLogger(scope string) pionLogging.LeveledLogger

NewLogger implements the interface for pion logging library so that this PionAdaptorFactory can be passed into webrtc api.

func (*PionAdaptorFactory) WithFields

WithFields a chainable wrapper to decorate a factory with extra attributes.

type PionAdaptorLogger

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

PionAdaptorLogger is wrapper around slog logger that implements LeveledLogger interface.

func (*PionAdaptorLogger) Debug

func (adaptor *PionAdaptorLogger) Debug(msg string)

func (*PionAdaptorLogger) Debugf

func (adaptor *PionAdaptorLogger) Debugf(format string, args ...any)

func (*PionAdaptorLogger) Error

func (adaptor *PionAdaptorLogger) Error(msg string)

func (*PionAdaptorLogger) Errorf

func (adaptor *PionAdaptorLogger) Errorf(format string, args ...any)

func (*PionAdaptorLogger) Info

func (adaptor *PionAdaptorLogger) Info(msg string)

func (*PionAdaptorLogger) Infof

func (adaptor *PionAdaptorLogger) Infof(format string, args ...any)

func (*PionAdaptorLogger) Trace

func (adaptor *PionAdaptorLogger) Trace(msg string)

func (*PionAdaptorLogger) Tracef

func (adaptor *PionAdaptorLogger) Tracef(format string, args ...any)

func (*PionAdaptorLogger) Warn

func (adaptor *PionAdaptorLogger) Warn(msg string)

func (*PionAdaptorLogger) Warnf

func (adaptor *PionAdaptorLogger) Warnf(format string, args ...any)

type PionFields

type PionFields map[string]any

Jump to

Keyboard shortcuts

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