Skip to content

feat: implement structured logging and environment-based log configuration in Flask backend#34

Open
A69SHUBHAM wants to merge 2 commits into
chaoss:mainfrom
A69SHUBHAM:feature/structured-logging
Open

feat: implement structured logging and environment-based log configuration in Flask backend#34
A69SHUBHAM wants to merge 2 commits into
chaoss:mainfrom
A69SHUBHAM:feature/structured-logging

Conversation

@A69SHUBHAM
Copy link
Copy Markdown

Summary

This PR replaces print statements with a structured logging system using Python's logging module and integrates environment-based configuration using python-dotenv.

Changes

  • Replaced all print() statements with Python logging module
  • Added structured log format with timestamps, module name, and log level
  • Implemented log levels (INFO, WARNING, ERROR, DEBUG)
  • Added logging for:
    • Incoming API requests
    • Outgoing responses
    • External API calls and failures
    • Exception handling
  • Integrated environment-based configuration using .env
  • Added LOG_LEVEL support to control verbosity (e.g., DEBUG, INFO)
  • Restored and ensured load_dotenv() is called at startup

Why this is needed

The previous implementation relied on print statements, which are not suitable for production environments. This change improves debugging, observability, and provides structured, configurable logs for better monitoring.

Testing

  • Verified logs for API requests and responses
  • Tested error scenarios → errors logged correctly
  • Tested LOG_LEVEL=DEBUG → verbose logs appear
  • Confirmed .env variables are loaded properly
  • Ensured no print statements remain in the backend

Impact

  • Improves debugging and observability
  • Makes backend more production-ready
  • Provides consistent and structured logging
  • Enables flexible configuration via environment variables

Closes #33

@A69SHUBHAM A69SHUBHAM force-pushed the feature/structured-logging branch from 5d711b9 to 082d927 Compare April 30, 2026 13:26
Signed-off-by: A69SHUBHAM <spacekrai0@gmail.com>
Signed-off-by: A69SHUBHAM <spacekrai0@gmail.com>
@A69SHUBHAM A69SHUBHAM force-pushed the feature/structured-logging branch from 082d927 to 859c146 Compare April 30, 2026 13:31
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.

Backend uses print statements instead of structured logging

1 participant