8000
Skip to content

v2.9.0

Latest

Choose a tag to compare

@github-actions github-actions released this 05 Nov 23:46
990fbe1

The Problem

go-libp2p 0.44 switched from go-log to slog, which broke visibility of go-libp2p logs for applications using go-log. Applications could no longer see go-libp2p logs or adjust their levels at runtime (see kubo#11035).

go-libp2p maintainers evaluated two options presented by Kubo maintainers for addressing this (details): fix the breaking change in go-libp2p, or require each application to add integration code. The manual integration approach was selected.

The Fix

This release adds SlogHandler() to bridge slog-based libraries back into go-log. Applications using go-log (>=2.9)+go-libp2p(>=0.45) need to add this to their init():

import (
    "log/slog"
    golog "github.com/ipfs/go-log/v2"
    "github.com/libp2p/go-libp2p/gologshim"
)

func init() {
    // Route all slog logs through go-log
    slog.SetDefault(slog.New(golog.SlogHandler()))

    // Connect go-libp2p to go-log
    gologshim.SetDefaultHandler(golog.SlogHandler())
}

After adding this:

  • go-libp2p logs appear in application output again
  • SetLogLevel("libp2p-swarm", "debug") works again
  • logs can be piped to dynamically created sinks, like ipfs log tail
  • All logs use go-log's formatting (JSON/color/nocolor)

More Info

See the README: Slog integration for details.

Full Changelog: v2.8.2...v2.9.0

Note

This release was brought to you by the Shipyard team.

0