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

logger: do not log stack w/ info(), debug() and spam() #5

Merged
merged 3 commits into from
May 20, 2019

Conversation

braydonf
Copy link
Contributor

@braydonf braydonf commented May 17, 2019

This reverts previous behavior to not include the stack for info(), debug() and spam() level logs and will continue to include the stack in all cases for error() and warning() logs as was previously resolved.

cc: @BluSyn

@BluSyn
Copy link
Contributor

BluSyn commented May 17, 2019

This works. I like the addition of tests.

👍

@braydonf
Copy link
Contributor Author

Great!

@pinheadmz
Copy link
Member

I'm unclear on the motivation - spam is the most verbose log level, I turn it on for testing & development, why exclude the stack traces?

@braydonf
Copy link
Contributor Author

braydonf commented May 17, 2019

I'm not aware of where spam is used for errors currently, see the level numbers defined at https://github.com/bcoin-org/blgr/blob/master/lib/logger.js#L796-L803

@pinheadmz
Copy link
Member

Right, exactly: log-level=spam reports ALL messages, it includes errors, warnings, infos, and debugs. When I set to spam I expect to see every single log message in the codebase

@braydonf
Copy link
Contributor Author

I think the idea is that only logger.warning and logger.error are used for unexpected errors, where a stack trace is useful, and other cases the error should be expected and thus the stack isn't needed.

@pinheadmz
Copy link
Member

Hm. One of the reasons this change is important is because of bcoin-org/bcoin#762, I assume that user's log was set to the default debug which wouldn't report stack traces after this is merged, right?

@braydonf
Copy link
Contributor Author

braydonf commented May 17, 2019

No, the stack would be displayed. I think you have the logger level setting confused with the logger level function. In this PR, logger.error always displays the stack trace, as does logger.warning.

@braydonf braydonf changed the title logger: do not log stack with info, debug and spam logger: do not log stack with info(), debug() and spam() May 17, 2019
@braydonf braydonf changed the title logger: do not log stack with info(), debug() and spam() logger: do not log stack w/ info(), debug() and spam() May 17, 2019
@braydonf braydonf changed the title logger: do not log stack w/ info(), debug() and spam() logger: do not log stack w/ info(), debug() and spam() May 17, 2019
This reverts previous behavior to not include the stack
for info(), debug() and spam() level logs and will continue
to include the stack in all cases for error() and warning()
logs as was previously resolved.
@nodech
Copy link
Member

nodech commented May 17, 2019

Warnings are used for logical warnings, where we know what happened and we are just announcing it (that's how I have seen it used at least). I am not sure if that needs stack traces.

errors definitely need stack traces.

@braydonf
Copy link
Contributor Author

braydonf commented May 17, 2019

The use of logger.warning with an instance of Error is very infrequent. There is one use of logger.warning with an Error instance in bcoin, see https://github.com/bcoin-org/bcoin/blob/master/lib/net/pool.js#L2172-L2181 I don't think it's an issue, and would be helpful.

@nodech
Copy link
Member

nodech commented May 17, 2019

I see that would definitely obscure the source. Would be nice to expand on those log messages as well, so you can get more context but that's part of the error messages not this PR.

So we have two usage, as errors that are not essential but could be important and user warnings that are just informational and not an error.

@BluSyn BluSyn merged commit 5242a72 into bcoin-org:master May 20, 2019
@braydonf braydonf deleted the logerror branch May 20, 2019 23:25
This was referenced Apr 22, 2020
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

Successfully merging this pull request may close these issues.

4 participants