slogadapter

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package slogadapter bridges *slog.Logger callers (notably github.com/prometheus/exporter-toolkit) onto the package-level logrus logger used by the rest of junos_exporter. Records keep their original level and structured attributes instead of being collapsed into a pre-rendered text line.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() *slog.Logger

New returns a *slog.Logger backed by a Handler that forwards to the package-level logrus logger.

Types

type Handler

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

Handler implements slog.Handler. The zero value is ready to use.

func (*Handler) Enabled

func (h *Handler) Enabled(_ context.Context, lvl slog.Level) bool

Enabled lets logrus's current level filter slog records before any work (attr collection, string formatting) is done.

func (*Handler) Handle

func (h *Handler) Handle(_ context.Context, r slog.Record) error

Handle forwards r to logrus at the corresponding level, with all attrs (those set via WithAttrs plus those on the record) as logrus fields.

func (*Handler) WithAttrs

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

WithAttrs returns a new Handler whose Handle calls will include attrs in every emitted record.

func (*Handler) WithGroup

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

WithGroup returns a new Handler that prefixes the keys of subsequent attrs with name (joined by dots, per slog conventions).

Jump to

Keyboard shortcuts

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