-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[configurator] Expose log level env variable #3845
base: master
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThe changes in this pull request introduce a new version, 5.8.1, for the configurator, which includes the feature of a configurable log level. The documentation and configuration files have been updated to reflect this new option, allowing users to specify their desired logging verbosity. The updates also include a new environment variable in the script that manages logging behavior. The overall structure of the documentation and configuration files remains largely unchanged, focusing on enhancing user control over logging settings. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (2)
configurator/translations/en.yaml (1)
28-31
: Enhance the log level descriptionThe addition of the log level configuration option is good, but the description could be more helpful to users.
Consider expanding the description to be more informative:
loglevel: name: Log level description: >- - The log level to use (default `info`). + Specify the logging verbosity. Available levels from most to least verbose: + `debug`, `info` (default), `warning`, `error`, `critical`. Setting a higher + level reduces log output. For example, `warning` will only show warning and + error messages.configurator/CHANGELOG.md (1)
3-5
: Enhance the changelog entry with more specific details.The changelog entry is clear but could be more informative. Consider expanding it to include the default value and available options:
## 5.8.1 -Expose configurable log level +Expose configurable log level (default: 'info', options: debug/info/warning/error/critical)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (5)
configurator/CHANGELOG.md
(1 hunks)configurator/DOCS.md
(1 hunks)configurator/config.yaml
(3 hunks)configurator/rootfs/etc/s6-overlay/s6-rc.d/configurator/run
(2 hunks)configurator/translations/en.yaml
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
configurator/CHANGELOG.md (6)
Pattern */**(html|markdown|md)
: - For instructional content in documentation, use a direct and authoritative tone. Avoid expressions of politeness such as 'may' or 'please', and ensure the goal of the instruction is fronted.
- Apply the Microsoft Style Guide to ensure documentation maintains clarity and conciseness.
- In step-by-step instructions, front the location phrase in the instructional sentence.
- In step-by-step instructions, front the 'goal' in the instructional sentence.
- In step-by-step instructions, if in doubt what to front, front the 'goal' before the location phrase in the instructional sentence.
- do not hyphenate terms like 'top-right' or 'bottom-left' with 'corner'
Pattern */**(html|markdown|md)
: - Use bold to mark UI strings.
- If "" are used to mark UI strings, replace them by bold.
Pattern */**(html|markdown|md)
: - Be brief in your replies and don't add fluff like "thank you for..." and "Please let me know if"
Pattern */**(html|markdown|md)
: - Use sentence-style capitalization also in headings.
Pattern */**(html|markdown|md)
: do not comment on HTML used for icons
Pattern */**(html|markdown|md)
: Avoid flagging inline HTML for embedding videos in future reviews for this repository.
configurator/DOCS.md (6)
Pattern */**(html|markdown|md)
: - For instructional content in documentation, use a direct and authoritative tone. Avoid expressions of politeness such as 'may' or 'please', and ensure the goal of the instruction is fronted.
- Apply the Microsoft Style Guide to ensure documentation maintains clarity and conciseness.
- In step-by-step instructions, front the location phrase in the instructional sentence.
- In step-by-step instructions, front the 'goal' in the instructional sentence.
- In step-by-step instructions, if in doubt what to front, front the 'goal' before the location phrase in the instructional sentence.
- do not hyphenate terms like 'top-right' or 'bottom-left' with 'corner'
Pattern */**(html|markdown|md)
: - Use bold to mark UI strings.
- If "" are used to mark UI strings, replace them by bold.
Pattern */**(html|markdown|md)
: - Be brief in your replies and don't add fluff like "thank you for..." and "Please let me know if"
Pattern */**(html|markdown|md)
: - Use sentence-style capitalization also in headings.
Pattern */**(html|markdown|md)
: do not comment on HTML used for icons
Pattern */**(html|markdown|md)
: Avoid flagging inline HTML for embedding videos in future reviews for this repository.
configurator/config.yaml (6)
Pattern */**(html|markdown|md)
: - For instructional content in documentation, use a direct and authoritative tone. Avoid expressions of politeness such as 'may' or 'please', and ensure the goal of the instruction is fronted.
- Apply the Microsoft Style Guide to ensure documentation maintains clarity and conciseness.
- In step-by-step instructions, front the location phrase in the instructional sentence.
- In step-by-step instructions, front the 'goal' in the instructional sentence.
- In step-by-step instructions, if in doubt what to front, front the 'goal' before the location phrase in the instructional sentence.
- do not hyphenate terms like 'top-right' or 'bottom-left' with 'corner'
Pattern */**(html|markdown|md)
: - Use bold to mark UI strings.
- If "" are used to mark UI strings, replace them by bold.
Pattern */**(html|markdown|md)
: - Be brief in your replies and don't add fluff like "thank you for..." and "Please let me know if"
Pattern */**(html|markdown|md)
: - Use sentence-style capitalization also in headings.
Pattern */**(html|markdown|md)
: do not comment on HTML used for icons
Pattern */**(html|markdown|md)
: Avoid flagging inline HTML for embedding videos in future reviews for this repository.
🔇 Additional comments (4)
configurator/config.yaml (2)
2-2
: LGTM: Version bump follows semantic versioning
The minor version increment is appropriate for adding a new configuration option.
46-46
: LGTM: Log level schema is well-defined
The schema correctly defines the standard Python logging levels in order of verbosity, ensuring type safety through enumeration.
configurator/rootfs/etc/s6-overlay/s6-rc.d/configurator/run (2)
10-10
: LGTM! Export declaration follows established patterns
The HC_LOGLEVEL export declaration is consistent with other environment variable exports and follows the existing naming convention.
Line range hint 10-36
: Verify configurator's handling of HC_LOGLEVEL
Let's ensure that:
- The configurator code actually uses this environment variable
- The documentation properly explains the available log levels
✅ Verification successful
Let me check the actual content of these files to verify how HC_LOGLEVEL is used and documented.
HC_LOGLEVEL implementation is properly documented and configured
The verification shows that:
- The
loglevel
option is well documented in DOCS.md with a clear description - The config schema correctly defines allowed values: debug, info, warning, error, critical
- The option is properly translated in en.yaml with a clear name and description
- The environment variable HC_LOGLEVEL is exported and set with the configured value, defaulting to 'info'
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check if configurator code references HC_LOGLEVEL
rg -l "HC_LOGLEVEL|loglevel" configurator/
# Check if documentation mentions the new option
rg -l "loglevel" configurator/DOCS.md configurator/config.yaml configurator/CHANGELOG.md
Length of output: 319
Script:
#!/bin/bash
# Check the documentation of loglevel
echo "=== DOCS.md ==="
rg -A 5 "loglevel" configurator/DOCS.md
echo -e "\n=== config.yaml ==="
rg -A 5 "loglevel" configurator/config.yaml
echo -e "\n=== translations/en.yaml ==="
rg -A 5 "loglevel" configurator/translations/en.yaml
echo -e "\n=== Looking for HC_LOGLEVEL usage in configurator ==="
rg "HC_LOGLEVEL" configurator/
Length of output: 1122
@@ -33,6 +33,7 @@ options: | |||
- .storage | |||
- deps | |||
ssh_keys: [] | |||
loglevel: info |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider changing default log level to 'warning'
The PR's objective is to reduce "logspam" from HTTP request logging at 'info' level. However, keeping 'info' as the default maintains the same verbose logging behavior. Consider defaulting to 'warning' to address the stated problem while allowing users to opt-in to more verbose logging if needed.
- loglevel: info
+ loglevel: warning
📝 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.
loglevel: info | |
loglevel: warning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now the PR was only meant to allow the user to reduce logging verbosity and not change defaults. If maintainers agree I am very happy to set it to 'warning' instead, though. It is really unnecessary to log http requests by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mueslo Exposing the log level configuration without changing the default maintains current behavior, allowing users to adjust logging verbosity as needed.
bashio::config.has_value 'loglevel' \ | ||
&& HC_LOGLEVEL="$(bashio::config 'loglevel')" || HC_LOGLEVEL=info |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider improvements to the log level configuration
- The default level of 'info' doesn't address the PR's objective of reducing logspam. Consider defaulting to 'warning' instead.
- There's no validation of allowed log levels, which could lead to runtime errors if invalid values are provided.
- The syntax could be simplified using
bashio::config.get
with a default value.
Consider this alternative implementation:
-bashio::config.has_value 'loglevel' \
- && HC_LOGLEVEL="$(bashio::config 'loglevel')" || HC_LOGLEVEL=info
+# Validate log level
+LOGLEVEL="$(bashio::config.get 'loglevel' 'warning')"
+if [[ ! "${LOGLEVEL}" =~ ^(debug|info|warning|error|critical)$ ]]; then
+ bashio::log.error "Invalid log level: ${LOGLEVEL}"
+ bashio::log.error "Valid options are: debug, info, warning, error, critical"
+ bashio::exit.nok
+fi
+HC_LOGLEVEL="${LOGLEVEL}"
📝 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.
bashio::config.has_value 'loglevel' \ | |
&& HC_LOGLEVEL="$(bashio::config 'loglevel')" || HC_LOGLEVEL=info | |
# Validate log level | |
LOGLEVEL="$(bashio::config.get 'loglevel' 'warning')" | |
if [[ ! "${LOGLEVEL}" =~ ^(debug|info|warning|error|critical)$ ]]; then | |
bashio::log.error "Invalid log level: ${LOGLEVEL}" | |
bashio::log.error "Valid options are: debug, info, warning, error, critical" | |
bashio::exit.nok | |
fi | |
HC_LOGLEVEL="${LOGLEVEL}" |
### Option: `loglevel` (optional) | ||
|
||
The loglevel to pass to hass-configurator (default 'info'). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Enhance the loglevel option documentation
The documentation for the loglevel option needs more detail to help users make informed decisions.
Apply this diff to improve the documentation:
### Option: `loglevel` (optional)
-The loglevel to pass to hass-configurator (default 'info').
+Specify the log level for the File editor add-on. Valid values:
+
+- `debug`: Show all logs, including detailed debugging information
+- `info`: Show informational messages, warnings, and errors (default)
+- `warning`: Show only warning and error messages
+- `error`: Show only error messages
+- `critical`: Show only critical error messages
+
+Set to `warning` or higher to reduce log volume from HTTP requests.
📝 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.
### Option: `loglevel` (optional) | |
The loglevel to pass to hass-configurator (default 'info'). | |
### Option: `loglevel` (optional) | |
Specify the log level for the File editor add-on. Valid values: | |
- `debug`: Show all logs, including detailed debugging information | |
- `info`: Show informational messages, warnings, and errors (default) | |
- `warning`: Show only warning and error messages | |
- `error`: Show only error messages | |
- `critical`: Show only critical error messages | |
Set to `warning` or higher to reduce log volume from HTTP requests. |
It would be nice to reduce unnecessary logspam, e.g. that every single HTTP request gets logged in the default 'info' loglevel of
hass-configurator
, with no easy way to fix this. And it does indeed have a loglevel flag ( https://github.com/danielperna84/hass-configurator/blob/397bda2f9131d2c1c979bf01391745699852b049/hass_configurator/configurator.py#L105 ) that is however not exposed in the Home Assistant addon configuration.Summary by CodeRabbit
New Features
loglevel
for the "File editor" add-on.Documentation
loglevel
feature.loglevel
option.Configuration Updates
loglevel
option with a default value of 'info'.