logdown.js
logdown.js copied to clipboard
Specify log level with Node environment variable
With NODE_DEBUG it's possible to specify logger names which should be active. Is there also a setting to specify the log level?
For example, I would like to see only logs from "foo" which have log level "warning" or "error" but no "debug", "info" and/or "log".
I would like to set something like:
NODE_DEBUG=foo NODE_DEBUG_LEVEL=error,warn node example/node.js
This is a really important feature.
That's indeed a good feature to have. Are those values enough?:
- log (should console info as well)
- warn -error
I suggest to use the 5 default levels from Logdown which are:
- debug
- log
- info
- warn
- error
When setting the log level to "error", then you will only get error reports. If you set the level to "warn", then you will get warnings and errors. When setting it to "info", you will get infos, warnings and errors. So the idea is that you get the level specified and all above.
I thought log and info meant the same thing in modern implementations since it behaves the same in Chrome.
But it's on the spec so I say we go with what @bennyn is proposing.
Also, we need an env var for the browser as we do for window.localStorage.debug.
How about window.localStorage.debugLevel?
To clarify, if I set NODE_DEBUG_LEVEL as debug I would get:
- debug
- log
- info
- warn
- error
If I set NODE_DEBUG_LEVEL as warn I would get
- warn
- error
Is that how you see it?
Yes, exactly! 👍