mirror of
https://github.com/libp2p/go-libp2p.git
synced 2025-12-24 13:29:35 +08:00
docs(gologshim): use golog.SlogHandler() in integration example
update integration example to use golog.SlogHandler() instead of slog.Default().Handler(). more explicit and works even when GOLOG_CAPTURE_DEFAULT_SLOG=false.
This commit is contained in:
@@ -13,14 +13,19 @@
|
||||
//
|
||||
// Applications can optionally connect go-libp2p to go-log by calling SetDefaultHandler:
|
||||
//
|
||||
// import golog "github.com/ipfs/go-log/v2"
|
||||
//
|
||||
// func init() {
|
||||
// gologshim.SetDefaultHandler(slog.Default().Handler())
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user