Feature: Make LOG_LEVEL configurable #194
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces configurable logging levels to enhance flexibility and reduce unnecessary log output in production environments. The default log level remains
INFO, ensuring backward compatibility.Background
While running
fusionin a Docker container, I observed excessive log growth due to the defaultINFOlogging level. This can lead to storage concerns in long-running production deployments where verbose logs are unnecessary. Currently, the application does not support log level configuration, limiting users' ability to control log output.Changes
LOG_LEVELenvironment variableINFOas the default level when:LOG_LEVELis unsetDEBUGINFOWARN(orWARNING)ERRORConfiguration
The log level can be configured through:
-eflag)Example Docker command:
docker run --rm -it -d -p 9080:8080 -e PASSWORD="fusion" -e LOG_LEVEL=ERROR your_image_idExample (Before implementing configurable log level)
this is the sample of my container's log after running the app for the first time, log in and then refreshing the feed several times
docker logs -f 5b879037a436 {"time":"2025-09-20T15:32:22.21879047Z","level":"WARN","msg":"no configuration file found at .env"} ⇨ http server started on [::]:8080 {"time":"2025-09-20T15:32:45.445553301Z","level":"ERROR","msg":"code=401, message=Unauthorized","uri":"/api/groups","status":401} {"time":"2025-09-20T15:32:45.447826329Z","level":"ERROR","msg":"code=401, message=Unauthorized","uri":"/api/feeds","status":401} {"time":"2025-09-20T15:32:45.451687128Z","level":"ERROR","msg":"code=401, message=Unauthorized","uri":"/api/items?page=1&page_size=12&unread=true","status":401} {"time":"2025-09-20T15:32:49.326484802Z","level":"ERROR","msg":"code=400, message=Password is a required field.","uri":"/api/sessions","status":400} {"time":"2025-09-20T15:32:52.736130333Z","level":"ERROR","msg":"code=401, message=Wrong password","uri":"/api/sessions","status":401} {"time":"2025-09-20T15:33:02.16680381Z","level":"INFO","msg":"REQUEST","uri":"/api/sessions","status":201} {"time":"2025-09-20T15:33:02.182048779Z","level":"INFO","msg":"REQUEST","uri":"/api/groups","status":200} {"time":"2025-09-20T15:33:02.187393763Z","level":"INFO","msg":"REQUEST","uri":"/api/feeds","status":200} {"time":"2025-09-20T15:33:02.192042578Z","level":"INFO","msg":"REQUEST","uri":"/api/items?page=1&page_size=12&unread=true","status":200} {"time":"2025-09-20T15:33:23.868491987Z","level":"INFO","msg":"REQUEST","uri":"/api/groups","status":200} {"time":"2025-09-20T15:33:23.874223724Z","level":"INFO","msg":"REQUEST","uri":"/api/feeds","status":200} {"time":"2025-09-20T15:33:23.87660873Z","level":"INFO","msg":"REQUEST","uri":"/api/items?page=1&page_size=12&unread=true","status":200} {"time":"2025-09-20T15:33:26.176484064Z","level":"INFO","msg":"REQUEST","uri":"/api/groups","status":200} {"time":"2025-09-20T15:33:26.179167408Z","level":"INFO","msg":"REQUEST","uri":"/api/items?page=1&page_size=12&unread=true","status":200} {"time":"2025-09-20T15:33:26.179401996Z","level":"INFO","msg":"REQUEST","uri":"/api/feeds","status":200} {"time":"2025-09-20T15:33:26.297843776Z","level":"INFO","msg":"REQUEST","uri":"/api/groups","status":200} {"time":"2025-09-20T15:33:26.299729473Z","level":"INFO","msg":"REQUEST","uri":"/api/feeds","status":200} {"time":"2025-09-20T15:33:26.302641935Z","level":"INFO","msg":"REQUEST","uri":"/api/items?page=1&page_size=12&unread=true","status":200} {"time":"2025-09-20T15:33:26.536957401Z","level":"INFO","msg":"REQUEST","uri":"/api/groups","status":200} {"time":"2025-09-20T15:33:26.541698533Z","level":"INFO","msg":"REQUEST","uri":"/api/feeds","status":200} {"time":"2025-09-20T15:33:26.541884687Z","level":"INFO","msg":"REQUEST","uri":"/api/items?page=1&page_size=12&unread=true","status":200} {"time":"2025-09-20T15:33:26.72061006Z","level":"INFO","msg":"REQUEST","uri":"/api/groups","status":200} {"time":"2025-09-20T15:33:26.723198152Z","level":"INFO","msg":"REQUEST","uri":"/api/feeds","status":200} {"time":"2025-09-20T15:33:26.725941943Z","level":"INFO","msg":"REQUEST","uri":"/api/items?page=1&page_size=12&unread=true","status":200} {"time":"2025-09-20T15:33:26.861880937Z","level":"INFO","msg":"REQUEST","uri":"/api/groups","status":200} {"time":"2025-09-20T15:33:26.86318292Z","level":"INFO","msg":"REQUEST","uri":"/api/feeds","status":200} {"time":"2025-09-20T15:33:26.863403438Z","level":"INFO","msg":"REQUEST","uri":"/api/items?page=1&page_size=12&unread=true","status":200} {"time":"2025-09-20T15:33:27.001681713Z","level":"INFO","msg":"REQUEST","uri":"/api/groups","status":200} {"time":"2025-09-20T15:33:27.002875484Z","level":"INFO","msg":"REQUEST","uri":"/api/feeds","status":200} {"time":"2025-09-20T15:33:27.003817493Z","level":"INFO","msg":"REQUEST","uri":"/api/items?page=1&page_size=12&unread=true","status":200} {"time":"2025-09-20T15:33:27.131038896Z","level":"INFO","msg":"REQUEST","uri":"/api/groups","status":200} {"time":"2025-09-20T15:33:27.13325928Z","level":"INFO","msg":"REQUEST","uri":"/api/items?page=1&page_size=12&unread=true","status":200} {"time":"2025-09-20T15:33:27.134464665Z","level":"INFO","msg":"REQUEST","uri":"/api/feeds","status":200} {"time":"2025-09-20T15:33:27.266195309Z","level":"INFO","msg":"REQUEST","uri":"/api/groups","status":200} {"time":"2025-09-20T15:33:27.269629643Z","level":"INFO","msg":"REQUEST","uri":"/api/feeds","status":200} {"time":"2025-09-20T15:33:27.270089514Z","level":"INFO","msg":"REQUEST","uri":"/api/items?page=1&page_size=12&unread=true","status":200}Example (After implementing configurable log level)
After the feature has been made, I run the app using docker and set the
LOG_LEVELvalue using this command:docker run --rm -it -d -p 9080:8080 -e PASSWORD="fusion" -e LOG_LEVEL=ERROR aac4f28d8385, log in and then refresh the feed several times. Below are the output log on my containerdocker logs -f a3800b40f095 {"time":"2025-09-20T15:35:10.827919642Z","level":"WARN","msg":"no configuration file found at .env"} ⇨ http server started on [::]:8080 {"time":"2025-09-20T15:35:57.027358891Z","level":"ERROR","msg":"code=401, message=Unauthorized","uri":"/api/groups","status":401} {"time":"2025-09-20T15:35:57.030445275Z","level":"ERROR","msg":"code=401, message=Unauthorized","uri":"/api/feeds","status":401} {"time":"2025-09-20T15:35:57.030515984Z","level":"ERROR","msg":"code=401, message=Unauthorized","uri":"/api/items?page=1&page_size=12&unread=true","status":401}Any feedback to better improve this PR is appreciated