unjs / consola

🐨 Elegant Console Logger for Node.js and Browser
Other
6.12k stars 175 forks source link

Easiest way to process.exit on with `consola.fatal` #314

Open uncenter opened 3 months ago

uncenter commented 3 months ago

Environment

N/A

Reproduction

N/A

Describe the bug

I'm a bit confused on how I can get consola.fatal to log and then fail the process. I was surprised to see that, as far as I can tell, fatal is identical to error? I would expect different behavior, such as exiting by default!

Additional context

While searching this repo for this behavior I came across https://github.com/unjs/consola/issues/30#issuecomment-459341549:

consola.on('fatal', (message) => {
   process.exit(1)
})

I really like this (nonexistent) API. I found _wrapLogFn but it doesn't seem applicable here.

Logs

No response