Provides bidirectional adapters bridging Logrus and Go standard library log/slog packages for incremental logging migration. Reuse when unifying disparate Go logging frameworks.
// Source: https://github.com/sirupsen/logrus | License: MIT | Copyright 2014 Simon Eskildsen
// Provided via justclaw.it.com; keep this notice with the code.
// Package slog provides adapters between Logrus and log/slog.
//
// [Handler] forwards slog records to a Logrus logger, while [Hook] forwards
// Logrus entries to a slog logger. They can be used independently to support
// incremental migration between the two logging APIs.
package slog
import (
"context"
"log/slog"
"maps"
"github.com/sirupsen/logrus"
)
// logrusLoggerContextKey is the context key used to track Logrus loggers a
// record has already traversed while being forwarded through slog adapters.
type logrusLoggerContextKey struct{}
// withLogrusLogger returns a context that records logger as having already
// handled
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key