File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,18 @@ func init() {
5959 //
6060 // go-log's init() installs its slog bridge via slog.SetDefault().
6161 // We pass that handler to gologshim so go-libp2p loggers use it.
62- gologshim .SetDefaultHandler (slog .Default ().Handler ())
62+ handler := slog .Default ().Handler ()
63+
64+ // Verify that slog.Default() is go-log's bridge via duck typing.
65+ // This catches misconfigurations where go-log's init() didn't run.
66+ type goLogBridge interface {
67+ GoLogBridge ()
68+ }
69+ if _ , ok := handler .(goLogBridge ); ! ok {
70+ panic ("slog.Default() is not go-log's bridge - go-log may not be properly initialized" )
71+ }
72+
73+ gologshim .SetDefaultHandler (handler )
6374}
6475
6576// declared as a var for testing purposes.
You can’t perform that action at this time.
0 commit comments