Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify log level with Node environment variable #227

Open
bennycode opened this issue Feb 9, 2020 · 8 comments
Open

Specify log level with Node environment variable #227

bennycode opened this issue Feb 9, 2020 · 8 comments

Comments

@bennycode
Copy link
Collaborator

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
@rNoz
Copy link

rNoz commented Feb 24, 2020

This is a really important feature.

@caiogondim
Copy link
Owner

That's indeed a good feature to have.
Are those values enough?:

  • log (should console info as well)
  • warn
    -error

@bennycode
Copy link
Collaborator Author

I suggest to use the 5 default levels from Logdown which are:

  1. debug
  2. log
  3. info
  4. warn
  5. 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.

@caiogondim
Copy link
Owner

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.

@caiogondim
Copy link
Owner

Also, we need an env var for the browser as we do for window.localStorage.debug.

@bennycode
Copy link
Collaborator Author

How about window.localStorage.debugLevel?

@caiogondim
Copy link
Owner

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?

@bennycode
Copy link
Collaborator Author

Yes, exactly! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants