Skip to content

Logging init config logic minor modifications #48

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
4 changes: 2 additions & 2 deletions application/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
from werkzeug.exceptions import HTTPException
from werkzeug.serving import WSGIRequestHandler

logger = logging.getLogger(__name__)

try:
with open('log_config.yaml') as config_file:
config = yaml.safe_load(config_file.read())
logging.config.dictConfig(config)
logger = logging.getLogger(__name__)
except Exception:
# Fallback to a basic configuration
logging.basicConfig(format='%(asctime)s %(levelname)s [%(name)s:%(lineno)d] %(message)s', level=logging.INFO, force=True)
logger = logging.getLogger(__name__)
logger.exception("Logging setup failed")
else:
logger.warning("Logging setup is completed with config=%s", config)
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Consider limiting logged configuration details.

Logging the entire configuration object could potentially expose sensitive information (like log file paths, credentials in custom handlers) and create verbose log entries.

- logger.warning("Logging setup is completed with config=%s", config)
+ logger.warning("Logging setup completed successfully")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
logger.warning("Logging setup is completed with config=%s", config)
logger.warning("Logging setup completed successfully")

Expand Down
Loading