package gologshim

Import Path
	github.com/libp2p/go-libp2p/gologshim (on go.dev)

Dependency Relation
	imports 7 packages, and imported by 33 packages

Involved Source Files Package gologshim provides slog-based logging for go-libp2p that works standalone or integrates with go-log for unified log management across IPFS/libp2p applications, without adding go-log as a dependency. # Usage Create loggers using the Logger function: var log = gologshim.Logger("subsystem") log.Debug("message", "key", "value") # Integration with go-log Applications can optionally connect go-libp2p to go-log by calling SetDefaultHandler: import golog "github.com/ipfs/go-log/v2" func init() { gologshim.SetDefaultHandler(golog.SlogHandler()) } When integrated, go-libp2p logs use go-log's formatting and can be controlled programmatically via go-log's SetLogLevel("subsystem", "level") API to adjust log verbosity per subsystem at runtime without restarting. Note: SlogHandler() works even when GOLOG_CAPTURE_DEFAULT_SLOG=false, making it more reliable than using slog.Default().Handler(). # Standalone Usage Without calling SetDefaultHandler, gologshim creates standalone slog handlers writing to stderr. This mode is useful when go-log is not present or when you want independent log configuration via backward-compatible (go-log) environment variables: - GOLOG_LOG_LEVEL: Set log levels per subsystem (e.g., "error,ping=debug") - GOLOG_LOG_FORMAT/GOLOG_LOG_FMT: Output format ("json" or text) - GOLOG_LOG_ADD_SOURCE: Include source location (default: true) - GOLOG_LOG_LABELS: Add key=value labels to all logs For integration details, see: https://github.com/ipfs/go-log/blob/master/README.md#slog-integration Note: This package exists as an intermediate solution while go-log uses zap internally. If go-log migrates from zap to native slog, this bridge layer could be simplified or removed entirely.
Package-Level Type Names (only one)
/* sort by: | */
(*Config) LevelForSystem(system string) slog.Level
Package-Level Functions (total 2)
Logger returns a *slog.Logger with a logging level defined by the GOLOG_LOG_LEVEL env var. Supports different levels for different systems. e.g. GOLOG_LOG_LEVEL=foo=info,bar=debug,warn sets the foo system at level info, the bar system at level debug and the fallback level to warn.
SetDefaultHandler allows an application to change the underlying handler used by gologshim as long as it's changed *before* the first log by the logger.
Package-Level Variables (only one)