Comments (11)
Yes, I remove
-t
flag when logging in verbose mode. In verbose_mode, it is automatically tagging the logged message by the procd service name and if I pass a tag, then the message is logged twice
What do you think about adding a new "debug mode" to turn this on?
In verbose mode we could avoid using it. In debug mode we would know (and document) that any output is sent to the logging facility, causing some output to be repeated, Or alternatively, we could even modify our log function to use echo instead of logger
.
from openwrt-openwisp-monitoring.
@feckert Here subroutine refers to creating a specific function for logger calls?
from openwrt-openwisp-monitoring.
@devkapilbansal In the described scripts in my description there is no function for the logger call.
Following the pattern don't repeat your self I would suggest that we add the following subroutine.
log "<level>" "<message>"
This makes the code clearer because it is one liner.
from openwrt-openwisp-monitoring.
@devkapilbansal I have noticed that there are quite a few instances of the calls to logger
in which the -t
(tag) flag is not used. Is that on purpose?
I think all logger calls should have this.
I also second the proposal of @feckert, I think we can move the -t openwisp_monitoring
to our function which we can then reuse. We should also write it so we don't have to pass "daemon.err" but only "err", moreover, we could default the log level to info so that in many cases the call to the logging facility will be very short.
I think this would make the code more readable since we have many calls to the logger.
from openwrt-openwisp-monitoring.
Yes, I remove -t
flag when logging in verbose mode. In verbose_mode, it is automatically tagging the logged message by the procd service name and if I pass a tag, then the message is logged twice
from openwrt-openwisp-monitoring.
@devkapilbansal one more thing, regarding verbose mode, I think we could handle the verbose output using this function we're imagining here.
We have a lot of if/else in the code for verbose messages which are harming the readability of the agent code, what about solving this with our function?
Eg:
log "<message>" "<level>" "<verbose_message>" "<non_verbose_message_only>"
Practical examples below.
Message shown regardless of mode
log "Something happened." "warn"
Result is shown both in verbose mode and non verbose:
Sep 18 18:18:20 Router daemon.warn openwisp-monitoring: Something happened.
Message + verbose appended
log "Something happened." "warn" "Verbose output containing more detailed info here."
Result seen in non-verbose mode:
Sep 18 18:18:20 Router daemon.warn openwisp-monitoring: Something happened.
Result seen in verbose mode:
Sep 18 18:18:20 Router daemon.warn openwisp-monitoring: Something happened. Verbose output containing more detailed info here.
Verbose message only
log "" "warn" "Message shown only in verbose mode."
Result seen only in verbose mode (in non-verbose mode the log line is not executed at all):
Sep 18 18:18:20 Router daemon.warn openwisp-monitoring: Message shown only in verbose mode.
Non verbose message
log "Something happened." "warn" "More details here..." "Run in verbose mode to find out more."
Non verbose result:
Sep 18 18:18:20 Router daemon.warn openwisp-monitoring: Something happened. Run in verbose mode to find out more.
Verbose result:
Sep 18 18:18:20 Router daemon.warn openwisp-monitoring: Something happened. More details here...
from openwrt-openwisp-monitoring.
Can we do something like this 👇
log -v -w "message"
-v --> Verbose mode
-w --> Warning
-e --> Error
-i --> Info
-n --> Non Verbose mode
When -n
is passed, the message will be shown in both verbose_mode
and non-verbose mode
.
In the case of -v
, the message will be shown in verbose_mode
only.
from openwrt-openwisp-monitoring.
Can we do something like this point_down
log -v -w "message"
-v --> Verbose mode -w --> Warning -e --> Error -i --> Info -n --> Non Verbose mode
When
-n
is passed, the message will be shown in bothverbose_mode
andnon-verbose mode
. In the case of-v
, the message will be shown inverbose_mode
only.
Sounds good, but how can all the cases mentioned in #57 (comment) be covered by this?
Can you please provide some examples of how it's going to look like?
The cases to cover are quite a bit and that draft idea doesn't seem to me it can cover them all.
from openwrt-openwisp-monitoring.
Here are some examples on how it will work:
Message shown regardless of mode
log -n -w "This is a warning"
The result will be shown in both verbose and non-verbose mode
Oct 14 03:46:15 Router daemon.warn openwisp-monitoring: This is a warning
Verbose mode only
log -v -e "This is an error"
Result:
Oct 14 03:46:15 Router daemon.err openwisp-monitoring: This is an error
I don't take the other two cases into consideration as we are handling them in if-else to stop redundant messages in non-verbose mode as found here.
I added a commit to show how I am approaching this: d965c42
from openwrt-openwisp-monitoring.
Ok but what about all the other cases?
There are cases in which in verbose mode we display additional info.
Here are some examples on how it will work:
Message shown regardless of mode
log -n -w "This is a warning"
I think -n should precede the message, eg: -n "This is a warning"
Verbose mode only
log -v -e "This is an error"
Same here, I think -v should precede the message, eg: -v "This is a warning"
.
So if we need to display a message that in verbose mode should contain more info we may be able to do:
log -e -n "Error detected" -v "More information here"
These combinations should cover all the most critical cases, if there are other cases to handle we could just simplify. What do you think?
from openwrt-openwisp-monitoring.
@jedboywonder these messages are out of topic here, I am going to delete them.
Django can be configure to send logs to a log collector. Use the general chat to ask questions.
from openwrt-openwisp-monitoring.
Related Issues (20)
- [bug] Do not retry sending data if HTTP response is 400 bad request HOT 1
- [bug] None is not of type 'object' HOT 2
- [change] Stop sending data on repeated 404 responses HOT 3
- [feature] Add retry mechanism with randomized backoff for HTTP requests
- [feature] Add bootup_delay option
- [tests] Change JSON string assertions to data structure assertions
- Time display and adjustement HOT 2
- [bug/change] Do not add wireless interface information if channel is not available
- [enhancement] Add `htmode` to wireless interface
- [bug] 'pairs' on unexpected variable value HOT 2
- [change] Move VERSION out of /etc/openwisp/
- [bug] Spanning Tree Status shown incorrectly HOT 2
- [feature] Add more wifi station information HOT 1
- [ci] "Build and upload package" job fails when using github action cache
- [change] Introduce random pause in sending of accumulated data
- [docs] Add package installation instructions
- [bug] Agent crashes when using monitored_interfaces "wlan0 wlan1 br-lan"
- [feature] Allow recognizing wireguard interface as of type virtual HOT 2
- [bug] ULA prefix check is bugged HOT 6
- [feature] Restart/reload agent when openwisp-config is restarted
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openwrt-openwisp-monitoring.