-
-
Notifications
You must be signed in to change notification settings - Fork 69
[refactor] Move Logging from init.d to Agent
#229
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
base: master
Are you sure you want to change the base?
[refactor] Move Logging from init.d to Agent
#229
Conversation
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 |
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.
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 |
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.
You don't need this if statement. You can provide a default value in the assignment of the message variable.
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.
Why is the if [ -z "$message" ] check unnecessary when we already have local message="${2:-}"? Could you clarify the reasoning?
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.
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
|
Hey @okraits , I've made the suggested changes
|
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: