Skip to content
New issue

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

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

Already on GitHub? # to your account

Enable debug cookiecutter logging for deep debug #1470

Merged
merged 1 commit into from
Sep 30, 2023

Conversation

rmartin16
Copy link
Member

@rmartin16 rmartin16 commented Sep 29, 2023

Changes

  • Configure logging for cookiecutter before generating a template via cookiecutter.log.configure_logger()
  • This enables cookiecutter's debug output when Briefcase's "deep debug" is enabled via -vv
  • The changenote is misc since we already have a feature note for the addition of -vv support

Notes

  • cookiecutter uses the notorious logging package for its logging
    • By default, it appears that cookiecutter only configures logging handlers for its logging when using its CLI; therefore, cookiecutter doesn't enable any handlers for its logger when Briefcase generates a template.
    • Although, perhaps notably, they also don't configure a NullHandler by default....so, cookiecutter is likely to be subjected to a default handler if one is configured....but such is the life of using logging...
    • At any rate, since no handlers were configured before, this changes cookiecutter logging to output INFO and above by default.
    • Although, cookiecutter only appears to use logger.debug() and logger.error() right now...so, it shouldn't matter in reality.
    • Finally, cookiecutter deletes any existing handlers when configure_logger() is called....so, it is safe to call multiple times without concerns about duplicating handlers for the logger.
  • Additionally, I couldn't call configure_logger() in BaseCommand.__init__() because verbosity won't be set until parse_options() is called...and verbosity can technically change (although, it doesn't currently).

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@rmartin16 rmartin16 force-pushed the cookiecutter-debug-log branch from 1246230 to f82cc6f Compare September 29, 2023 17:55
Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. I can't imagine we'll need to turn this on very often, but it's good to know we have the option.

@freakboy3742 freakboy3742 merged commit 8daf920 into beeware:main Sep 30, 2023
@rmartin16 rmartin16 deleted the cookiecutter-debug-log branch September 30, 2023 04:37
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants