add ability to enable debug logging #2120
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🤔 What's changed?
Adds the ability to enable debug logging for Cucumber. This is done one of two ways:
DEBUG=cucumber
as an environment variable (leaning into the common https://www.npmjs.com/package/debug library)debug: true
to the environment object (an argument in all the API functions)As part of this, solidified the "logger" concept which is currently internal but will be exposed to plugins eventually. Previously it was a
Console
instance pointed at thestderr
stream. It essentially still is, but it's behind a facade with justdebug
,error
andwarn
methods. The thinking here is to reinforce that we should not be emitting lots of stuff, unless something is wrong or we have debug on, and that reporting is the domain of formatters.⚡️ What's your motivation?
It's hard to troubleshoot your setup in Cucumber. People regularly raise issues or try to get help from the community and it's hard to tell whether it's a bug or misconfiguration. Often it comes down to an experienced contributor spotting something, or a lot of back and forth to get to the bottom of an issue.
The debug logging added here is initially focused around configuration, since that's very much low hanging fruit for troubleshooting, but will be expanded in time to cover more stuff.
Another side of this problem is to emit warnings when things look like they might be configured wrong; that's valuable but out of scope here.
🏷️ What kind of change is this?
♻️ Anything particular you want feedback on?
Since the
debug
package is Node.js-specific, I've kept it towards the outside of the code, in the CLI. Also I thought JavaScript API consumers would want to be able to control debug logging regardless of environment variables, as some frameworks have their own kind of options for this.📋 Checklist:
This text was originally generated from a template, then edited by hand. You can modify the template here.