chore: Avoid logging a warning when LOG_LEVEL is unset#4497
Merged
polarathene merged 3 commits intomasterfrom Jun 2, 2025
Merged
chore: Avoid logging a warning when LOG_LEVEL is unset#4497polarathene merged 3 commits intomasterfrom
LOG_LEVEL is unset#4497polarathene merged 3 commits intomasterfrom
Conversation
casperklein
reviewed
Jun 1, 2025
georglauterbach
previously approved these changes
Jun 1, 2025
casperklein
previously approved these changes
Jun 1, 2025
Member
casperklein
left a comment
There was a problem hiding this comment.
One last thing: As the function serves only one purpose, we might rename it to something like:
__environment_variables_validate_log_level or __environment_variables_check_log_level_value
6a2057e
casperklein
approved these changes
Jun 2, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
When
LOG_LEVELis not explicitly set, DMS logs a warning early on:That is redundant (should only log when it's assigned an invalid value), so let's configure the fallback earlier and only log this when it has actually been set with an unexpected value.
I've additionally collapsed the series of conditionals against
LOG_LEVELto use a regex instead, then inversed the logic so we don't need a redundant branch.Reference:
If the assigned value to the
LOG_LEVELENV is invalid:LOG_LEVELtoinfoas a valid fallback value:VARSkey, which will store the variable into/etc/dms-settings(fixes the ENV when shelling into the container or when another service is started by supervisord like change detection or our setup CLI).LOG_LEVELvariable for any other script that may check it during startup.The default
LOG_LEVELis effectively alreadyinfowhen unset/invalid (this differs from the actual_logcall that takes an arg to classify a log by level before checkingLOG_LEVELto filter):docker-mailserver/target/scripts/helpers/log.sh
Lines 58 to 64 in ea03808
docker-mailserver/target/scripts/helpers/log.sh
Lines 114 to 126 in ea03808
Default/invalid
LOG_LEVELwould match this:docker-mailserver/target/scripts/helpers/log.sh
Line 63 in ea03808
Thus we only show
error,warn,infologs:docker-mailserver/target/scripts/helpers/log.sh
Lines 79 to 80 in ea03808
For historical PR reference of this logic:
Type of change
Checklist
CHANGELOG.mdMinor internal change, seems unnecessary to document in the changelog.