-
Notifications
You must be signed in to change notification settings - Fork 2
Add default LOGGING configuration to Django template #537
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
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: lucasrcezimbra <[email protected]>
{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/settings.py
Outdated
Show resolved
Hide resolved
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Join our Discord community for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive default logging configuration to the Django cookiecutter template to provide proper logging setup out-of-the-box for generated projects. The implementation follows the template's existing patterns using python-decouple for environment variable management and includes environment-aware formatter selection.
Key Changes
- Added complete LOGGING configuration with formatters, handlers, and loggers to
settings.pytemplate - Implemented environment-based configuration using
LOG_LEVELandDJANGO_LOG_LEVELvariables - Created comprehensive test suite to validate logging configuration across different template options
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/settings.py |
Adds LOGGING configuration with verbose/simple formatters, console handler, and loggers for Django, project-specific, and root logging |
tests/test_logging.py |
Adds test suite covering default configuration, custom project slugs, formatter selection, and staticfiles interaction |
Comments suppressed due to low confidence (1)
for more information, see https://pre-commit.ci
…ified LOG_LEVEL Co-authored-by: lucasrcezimbra <[email protected]>
lucasrcezimbra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have to add "from pythonjsonlogger.json import JsonFormatter", also add the dependency to pyproject
Added JsonFormatter import from pythonjsonlogger.json and python-json-logger dependency to pyproject.toml. Updated structured formatter to use JsonFormatter class instead of manual JSON formatting. The structured formatter now provides proper JSON logging using the industry-standard library. |
| psycopg = "3.2.9" | ||
| {%- endif %} | ||
| python-decouple = "3.8" | ||
| python-json-logger = "2.0.7" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest version is 3.3.0
| python-json-logger = "2.0.7" | |
| python-json-logger = "3.3.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated python-json-logger to version 3.3.0. Commit: 0af9c35
| }, | ||
| "{{ cookiecutter.project_slug }}": { | ||
| "handlers": ["console"], | ||
| "level": config("LOG_LEVEL", default="INFO"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not duplicate the LOG_LEVEL access. Define a setting like this:
LOG_LEVEL = config(...
Then use it in all places
| "level": config("LOG_LEVEL", default="INFO"), | |
| "level": LOG_LEVEL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defined LOG_LEVEL as a setting variable once and now reusing it throughout the configuration instead of duplicating config() calls. Commit: 0af9c35
Co-authored-by: lucasrcezimbra <[email protected]>
This PR adds a comprehensive default LOGGING configuration to the Django cookiecutter template, addressing the missing logging setup in generated projects.
Changes Made
LOGGING Configuration
Added a complete logging configuration to
settings.pytemplate with:LOG_LEVELandDJANGO_LOG_LEVELconfigurationEnvironment-Aware Configuration
The logging setup follows the template's existing patterns:
python-decouple'sconfig()for environment variable managementExample Generated Configuration
Testing
tests/test_logging.pyBenefits
Fixes #470.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
install.python-poetry.orgcurl -sSL REDACTED(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.