libp2p/js-libp2p

bug: @libp2p/logger doesn't work in service workers

SgtPooki opened this issue · 2 comments

When attempting to use @libp2p/logger in the service-worker gateway, logs generated by the service worker were not being logged until I explicitly overrode the @libp2p/logger's forComponent and prefixLogger functions.

see ipfs/service-worker-gateway#395

Repro repo at https://github.com/SgtPooki/libp2p-logger-bug-repro

You need to import enable from @libp2p/logger and not debug.

Part of the point of wrapping debug with @libp2p/logger is that it allows us to swap out the underlying log implementation without having to change any calling code which is what happened in #2648 - calling through to the underlying implementation directly defeats the whole purpose.

using enable from @libp2p/logger works, thanks