[refactor] Move Logging from init.d to Agent#229
Open
shwetd19 wants to merge 7 commits intoopenwisp:masterfrom
Open
[refactor] Move Logging from init.d to Agent#229shwetd19 wants to merge 7 commits intoopenwisp:masterfrom
init.d to Agent#229shwetd19 wants to merge 7 commits intoopenwisp:masterfrom
Conversation
okraits
reviewed
Feb 14, 2025
okraits
requested changes
Feb 14, 2025
openwisp-config/files/openwisp.agent
Outdated
| # Logging function | ||
| log_message() { | ||
| local level="$1" | ||
| local message="${2:-}" # Default to an empty string if the second argument is not provided |
Member
There was a problem hiding this comment.
I would make the message mandatory. For the level I would fall back to daemon.info if none is provided.
openwisp-config/files/openwisp.agent
Outdated
| local level="$1" | ||
| local message="${2:-}" # Default to an empty string if the second argument is not provided | ||
|
|
||
| if [ -z "$message" ]; then |
Member
There was a problem hiding this comment.
You don't need this if statement. You can provide a default value in the assignment of the message variable.
Author
There was a problem hiding this comment.
Why is the if [ -z "$message" ] check unnecessary when we already have local message="${2:-}"? Could you clarify the reasoning?
Member
There was a problem hiding this comment.
Hi @shwetd19
If you see the above comment, Oliver suggested a fall back when message is not provided. In that case, this check will be unnecessary
Author
|
Hey @okraits , I've made the suggested changes
|
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.
Checklist
Description:
This PR refactors the logging mechanism in the OpenWISP configuration system to centralize logging in the agent (
openwisp.agent) instead of directly using theloggercommand ininit.dscripts.Changes:
Removed Direct
loggerCalls:loggercalls fromopenwisp-reload-configandopenwisp.init.Added Logging to Agent:
log_messagefunction inopenwisp.agentto handle logging.--log-messageargument in the agent to log messages.Updated Scripts:
openwisp-reload-configto call the agent for logging via/usr/sbin/openwisp-config --log-message.Testing:
/usr/sbin/openwisp-reload-config.--log-messageargument with/usr/sbin/openwisp-config.Fixes: