Skip to content

feat: enable environment-based logging control via ENVIRONMENT and LOG_LEVEL - #497

Closed
MetehanAydemir wants to merge 4 commits into
kafein-technology:devfrom
MetehanAydemir:feat/env_based_logging_control
Closed

feat: enable environment-based logging control via ENVIRONMENT and LOG_LEVEL#497
MetehanAydemir wants to merge 4 commits into
kafein-technology:devfrom
MetehanAydemir:feat/env_based_logging_control

Conversation

@MetehanAydemir

Copy link
Copy Markdown

Summary

Resolves #486. The ENVIRONMENT and LOG_LEVEL values in backend/app/core/constants.py were hardcoded ("development" / "DEBUG"), so the corresponding environment variables — already plumbed into the containers by docker-compose.yml — had no effect. Logging behavior could not be changed per environment without editing code.

This reads both values from the environment, with the previous hardcoded values kept as defaults:

ENVIRONMENT = os.getenv("ENVIRONMENT", "development").lower()
LOG_LEVEL = os.getenv("LOG_LEVEL", "DEBUG").upper()

ENVIRONMENT's effect is logging-only (console format JSON vs. colored, level); it does not gate security, DB, or CORS behavior.

Testing

Verified against the built backend image via docker compose:

  • Default env → development / DEBUG (unchanged; no regression)
  • ENVIRONMENT=production LOG_LEVEL=WARNING → code now resolves production / WARNING
  • Under ENVIRONMENT=production, logs are emitted as JSON (was colored human-readable before)
  • Live container healthy after rebuild: GET /health and GET /api/v1/nodes both return 200

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.

2 participants