gajus / turbowatch

Extremely fast file change detector and task orchestrator for Node.js.
Other
943 stars 23 forks source link

Add a way to name `watch` instances #31

Open gajus opened 1 year ago

gajus commented 1 year ago

This is a problem when running multiple Turbowatch scripts, e.g. turbowatch **/turbowatch.ts

If the above execution produces these logs:

[13:12:10.202]   0ms debug @turbowatch #subscribe: generate (0ee94688): initial run...
[13:12:10.204]   2ms debug @turbowatch #subscribe: generate (0ee94688): started task
[13:12:10.204]   0ms debug @turbowatch #subscribe: build (c82d7857): initial run...
[13:12:10.205]   1ms debug @turbowatch #subscribe: build (c82d7857): started task

then there is no way of knowing which instance of turbowatch.ts these logs are originating from.

I think the solution is quite simple here. We just need to allow name property in defineConfig and prepend that to the trigger name, e.g.

[13:12:10.202]   0ms debug @turbowatch #subscribe: slonik:generate (0ee94688): initial run...
[13:12:10.204]   2ms debug @turbowatch #subscribe: utilities:generate (0ee94688): started task
[13:12:10.204]   0ms debug @turbowatch #subscribe: utilities:build (c82d7857): initial run...
[13:12:10.205]   1ms debug @turbowatch #subscribe: slonik:build (c82d7857): started task

My slight problem with this is that adding a variable length prefix will break log alignment. Something that needs to be considered if we want to maintain pretty output.