logging

package
v5.0.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogFilePath

func LogFilePath(logsDir, extensionName string, sessionStart time.Time) string

LogFilePath builds a log file path using OS-appropriate path separators.

Types

type ContextHandler

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

ContextHandler wraps another handler and injects dynamic context attributes.

func NewContextHandler

func NewContextHandler(inner slog.Handler, provider ContextProvider) *ContextHandler

NewContextHandler creates a handler that adds dynamic context to each record.

func (*ContextHandler) Enabled

func (h *ContextHandler) Enabled(ctx context.Context, level slog.Level) bool

Enabled delegates to the inner handler.

func (*ContextHandler) Handle

func (h *ContextHandler) Handle(ctx context.Context, r slog.Record) error

Handle adds dynamic context attributes and delegates to the inner handler.

func (*ContextHandler) WithAttrs

func (h *ContextHandler) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs returns a new ContextHandler with the given attributes.

func (*ContextHandler) WithGroup

func (h *ContextHandler) WithGroup(name string) slog.Handler

WithGroup returns a new ContextHandler with the given group.

type ContextProvider

type ContextProvider func() []slog.Attr

ContextProvider is a function that returns dynamic context attributes.

type DispatcherLogger

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

DispatcherLogger adapts *slog.Logger to the dispatcher.Logger interface.

func NewDispatcherLogger

func NewDispatcherLogger(logger *slog.Logger) *DispatcherLogger

NewDispatcherLogger creates a new DispatcherLogger wrapping a *slog.Logger.

func (*DispatcherLogger) Debug

func (l *DispatcherLogger) Debug(msg string, keysAndValues ...any)

Debug logs a debug message with optional key-value pairs.

func (*DispatcherLogger) Error

func (l *DispatcherLogger) Error(msg string, keysAndValues ...any)

Error logs an error message with optional key-value pairs.

func (*DispatcherLogger) Info

func (l *DispatcherLogger) Info(msg string, keysAndValues ...any)

Info logs an info message with optional key-value pairs.

type MultiHandler

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

MultiHandler fans out log records to multiple handlers. All handlers receive every record.

func NewMultiHandler

func NewMultiHandler(handlers ...slog.Handler) *MultiHandler

NewMultiHandler creates a handler that writes to all provided handlers.

func (*MultiHandler) Enabled

func (m *MultiHandler) Enabled(ctx context.Context, level slog.Level) bool

Enabled returns true if any handler is enabled for the given level.

func (*MultiHandler) Handle

func (m *MultiHandler) Handle(ctx context.Context, r slog.Record) error

Handle sends the record to all handlers.

func (*MultiHandler) WithAttrs

func (m *MultiHandler) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs returns a new MultiHandler with the given attributes added to all handlers.

func (*MultiHandler) WithGroup

func (m *MultiHandler) WithGroup(name string) slog.Handler

WithGroup returns a new MultiHandler with the given group added to all handlers.

type SlogManager

type SlogManager struct {

	// Callbacks for dynamic state (same interface as old Manager)
	GetMissionName  func() string
	GetMissionID    func() uint
	IsUsingLocalDB  func() bool
	IsStatusRunning func() bool
	// contains filtered or unexported fields
}

SlogManager manages slog-based logging with optional OTel integration.

func NewSlogManager

func NewSlogManager() *SlogManager

NewSlogManager creates a new slog-based logging manager.

func (*SlogManager) Flush

func (m *SlogManager) Flush(ctx context.Context) error

Flush forces a flush of OTel logs if available.

func (*SlogManager) Logger

func (m *SlogManager) Logger() *slog.Logger

Logger returns the configured slog.Logger.

func (*SlogManager) Setup

func (m *SlogManager) Setup(file io.Writer, level string, provider *sdklog.LoggerProvider)

Setup initializes the logging system with file and optional OTel output. If provider is nil, OTel logging is disabled.

func (*SlogManager) WriteLog

func (m *SlogManager) WriteLog(functionName, data, level string)

WriteLog writes a log entry with the specified function name, data, and level. This provides backward compatibility with the old Manager interface.

Jump to

Keyboard shortcuts

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