Optionally re-introduce bb_info_msg()
Between Busybox 1.24.2 and 1.25.0 the bb_info_msg() function was
eliminated and calls to it changed to be bb_error_msg(). The downside of
this is that daemons now log all messages to syslog at the LOG_ERR level
which makes it hard to filter errors from informational messages.
This change optionally re-introduces bb_info_msg(), controlled by a new
option FEATURE_SYSLOG_INFO, restores all the calls to bb_info_msg() that
were removed (only in applets that set logmode to LOGMODE_SYSLOG or
LOGMODE_BOTH), and also changes informational messages in ifplugd and
ntpd.
The code size change of this is as follows (using 'defconfig' on x86_64
with gcc 7.3.0-27ubuntu1~18.04)
function old new delta
bb_info_msg - 182 +182
bb_vinfo_msg - 27 +27
static.log7 194 198 +4
log8 190 191 +1
log5 190 191 +1
crondlog 45 - -45
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 3/0 up/down: 215/-45) Total: 170 bytes
If you don't care about everything being logged at LOG_ERR level
then when FEATURE_SYSLOG_INFO is disabled Busybox actually gets smaller:
function old new delta
static.log7 194 200 +6
log8 190 193 +3
log5 190 193 +3
syslog_level 1 - -1
bb_verror_msg 583 581 -2
crondlog 45 - -45
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 3/1 up/down: 12/-48) Total: -36 bytes
Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
diff --git a/networking/dnsd.c b/networking/dnsd.c
index 37a8030..f2c6bdd 100644
--- a/networking/dnsd.c
+++ b/networking/dnsd.c
@@ -133,7 +133,7 @@
}
if (OPT_verbose)
- bb_error_msg("name:%s, ip:%s", token[0], token[1]);
+ bb_info_msg("name:%s, ip:%s", token[0], token[1]);
/* sizeof(*m) includes 1 byte for m->name[0] */
m = xzalloc(sizeof(*m) + strlen(token[0]) + 1);
@@ -438,7 +438,7 @@
answstr = table_lookup(conf_data, type, query_string);
#if DEBUG
/* Shows lengths instead of dots, unusable for !DEBUG */
- bb_error_msg("'%s'->'%s'", query_string, answstr);
+ bb_info_msg("'%s'->'%s'", query_string, answstr);
#endif
outr_rlen = 4;
if (answstr && type == htons(REQ_PTR)) {
@@ -474,7 +474,7 @@
* RCODE = 0 "success"
*/
if (OPT_verbose)
- bb_error_msg("returning positive reply");
+ bb_info_msg("returning positive reply");
outr_flags = htons(0x8000 | 0x0400 | 0);
/* we have one answer */
head->nansw = htons(1);
@@ -539,7 +539,7 @@
{
char *p = xmalloc_sockaddr2dotted(&lsa->u.sa);
- bb_error_msg("accepting UDP packets on %s", p);
+ bb_info_msg("accepting UDP packets on %s", p);
free(p);
}
@@ -557,7 +557,7 @@
continue;
}
if (OPT_verbose)
- bb_error_msg("got UDP packet");
+ bb_info_msg("got UDP packet");
buf[r] = '\0'; /* paranoia */
r = process_packet(conf_data, conf_ttl, buf);
if (r <= 0)