[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: Applets send errors to syslog during normal, successful operation
From: Tito <farmatito () tiscali ! it>
Date: 2017-11-30 20:51:28
Message-ID: cb1a2945-860f-f738-9133-ba6d3f75a0fa () tiscali ! it
[Download RAW message or body]
On 11/30/2017 08:26 PM, Deweloper wrote:
> Hi
>
> Many applets are daemons (or can be run as daemons) and send messages to
> syslog. The problem is that the messages don't have accurate, individually
> assigned severity; they are all LOG_ERR. Effectively, system administrator sees
> a lot of ERRORs in the log even when everything goes well. It seems that libbb
> provides only bb_error_msg() as a convenient way to print a message (including
> sending it to syslog), while a more generic function taking severity as well
> would be needed instead. grep -r 'syslog(' shows that only some loginutils call
> syslog() directly. In other places bb_error_msg() is used even for
> informational or verbose debugging messages. Just have a look at output of
> grep -r 'bb_error_msg('
>
> Do you have an idea how to clean this up? Shouldn't these messages be sent to a
> new function, e.g. bb_msg(), which would additionally take "severity" argument?
> Lowering the hardcoded syslog_level=LOG_ERR globally is not an option because
> real errors must remain errors.
>
> Examples of invalid error messages from just 2 applets under "networking"
> subdirectory (ifplugd & udhcpc):
>
> ifplugd(wlan0): started: BusyBox v1.27.2 (2017-11-23 00:34:48 CET)
> ifplugd(wlan0): upping interface
> ifplugd(wlan0): using SIOCETHTOOL detection mode
> ifplugd(wlan0): link is up
> ifplugd(wlan0): executing '/etc/rc.d/ifplugd.sh wlan0 up'
> ifplugd(wlan0): exit code: 0
> udhcpc[997]: started, v1.27.2
> udhcpc[997]: sending discover
> udhcpc[997]: sending select for 192.168.1.222
> udhcpc[997]: lease of 192.168.1.222 obtained, lease time 86400
> _______________________________________________
Hi,
some hints for a solution to this problem could be:
1) you can set syslog_level = LOG_INFO before the bb_error_msg call
(or group of bb_error calls) and reset it to LOG_ERR after the call(s).
This could be useful to change just a few occurrences of bb_error or
it would lead to code bloat.
2) you can set logmode = LOGMODE_STDIO; before the bb_error_msg call
(or group of bb_error calls) and reset it to LOGMODE_SYSLOG after
the call(s) to remove the calls from syslog.
This could be useful to change just a few occurrences of
bb_error or it would lead to code bloat.
3) remove some of the bb_error_ calls if they are redundant(?).
4) create a function that changes syslog_level to LOG_INFO, add it to libbb,
and then change the code of the applets accordingly, for example:
void FAST_FUNC bb_info_msg(const char *s, ...)
{
va_list p;
#if ENABLE_FEATURE_SYSLOG
smallint syslog_level_old = syslog_level;
syslog_level = LOG_INFO;
#endif
va_start(p, s);
bb_verror_msg(s, p, NULL);
#if ENABLE_FEATURE_SYSLOG
syslog_level = syslog_level_old;
#endif
va_end(p);
}
I wonder if the compiler could be so smart to see that this is
the same as bb_error_msg when ENABLE_FEATURE_SYSLOG is not set
and optimize it out.
This code is untested. Just my 2 cents.
Hope this helps.
Ciao,
Tito
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic