logger

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(handlers ...slog.Handler) *slog.Logger

New creates a new slog.Logger with the given handlers.

func NewAxiomHandler

func NewAxiomHandler(ctx context.Context, otelService *observability.Service, dataset string, apiKey string, options ...Option) (slog.Handler, func(context.Context), error)

NewAxiomHandler creates a new Axiom log handler, emitting logs to the given dataset and authenticating with the given API key.

func NewAxiomHandlerFromEnv

func NewAxiomHandlerFromEnv(ctx context.Context, otelService *observability.Service, options ...Option) (slog.Handler, func(context.Context), error)

NewAxiomHandlerFromEnv creates a new Axiom log handler. It reads the following environment variables:

  • AXIOM_API_KEY: The Axiom API key.
  • AXIOM_LOGS_DATASET: The dataset where logs should be stored.

func NewConsoleHandler

func NewConsoleHandler(options ...Option) slog.Handler

NewConsoleHandler creates a new console log handler.

func NewLoggingProviderWithProcessors

func NewLoggingProviderWithProcessors(otelService *observability.Service, processors ...log.Processor) *log.LoggerProvider

NewLoggingProviderWithProcessors creates a new OpenTelemetry logger provider with the given processors.

func NewOtelHandler

func NewOtelHandler(ctx context.Context, otelService *observability.Service, options ...Option) (slog.Handler, func(context.Context), error)

NewOtelHandler creates a new OpenTelemetry log handler.

func NewOtelLogProcessor

func NewOtelLogProcessor(ctx context.Context, options ...Option) (log.Processor, error)

NewOtelLogProcessor creates a new OpenTelemetry HTTP log processor.

Types

type Option

type Option func(*Options)

func WithEndpointURL

func WithEndpointURL(endpoint string) Option

WithEndpointURL sets the target endpoint URL (scheme, host, port, path) the Exporter will connect to.

func WithExportInterval

func WithExportInterval(exportInterval time.Duration) Option

WithExportInterval sets the maximum duration between batched exports. If set to 0, logs will not be batched.

Defaults to 1s.

func WithHeaders

func WithHeaders(headers map[string]string) Option

WithHeaders sets headers to send on each HTTP request.

func WithLevel

func WithLevel(level slog.Level) Option

WithLevel sets the log level.

Defaults to slog.LevelInfo.

type Options

type Options struct {
	Level          slog.Level
	Endpoint       string
	Headers        map[string]string
	ExportInterval time.Duration
}

Options contain the configuration for logging.

Jump to

Keyboard shortcuts

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