braidnetworks / dynohot

Hot module reloading for nodejs
ISC License
89 stars 3 forks source link

Ability to control or turn off logging #4

Closed spence-s closed 10 months ago

spence-s commented 10 months ago

Have been playing with this as I get the chance and really enjoy using it!

Would you consider exposing a way to control the logs from the module, or maybe turn logs off?

laverdet commented 10 months ago

We could add a silent option, but the status updates are can be pretty important. And some notifications like uncaught exceptions in handlers probably should never be silenced. Is it just the "[hot] Loaded 1 new module, reevaluated 2 existing modules in 224ms." message that is bothering you?

spence-s commented 10 months ago

In an ideal world, I would like to be able to get informed of the lifecycle/errors etc by a message event:

That way, I could choose what to log.

https://nodejs.org/api/module.html#communication-with-module-customization-hooks


My specific use case is that I log in JSON and I have an external worker that processes my logs during development for pretty-printing. (standard usage of pino really)

but dynohot is outputting logs that I can't format or ignore

laverdet commented 10 months ago

Communication with module customization hooks

This actually communicates with the loader thread but in dynohot most of the interesting logic lives in the runtime which runs in the same context as the script.

Anyway I'll see about adding a way to listen for the log messages explicitly.