From 253c4e787a799a3e1f92957ed791b5222f8d2f64 Mon Sep 17 00:00:00 2001 From: James Byrne Date: Fri, 12 Apr 2019 17:01:51 +0000 Subject: 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 Signed-off-by: Denys Vlasenko --- libbb/verror_msg.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'libbb/verror_msg.c') diff --git a/libbb/verror_msg.c b/libbb/verror_msg.c index 22c30357b..6d3459905 100644 --- a/libbb/verror_msg.c +++ b/libbb/verror_msg.c @@ -12,7 +12,7 @@ #endif #if ENABLE_FEATURE_SYSLOG -smallint syslog_level = LOG_ERR; +static smallint syslog_level = LOG_ERR; #endif smallint logmode = LOGMODE_STDIO; const char *msg_eol = "\n"; @@ -154,7 +154,7 @@ void FAST_FUNC bb_verror_msg(const char *s, va_list p, const char* strerr) } # if ENABLE_FEATURE_SYSLOG if (logmode & LOGMODE_SYSLOG) { - syslog(LOG_ERR, "%s", msgc); + syslog(syslog_level, "%s", msgc); } # endif free(msgc); @@ -180,3 +180,21 @@ void FAST_FUNC bb_error_msg(const char *s, ...) bb_verror_msg(s, p, NULL); va_end(p); } + +#if ENABLE_FEATURE_SYSLOG_INFO +void FAST_FUNC bb_vinfo_msg(const char *s, va_list p) +{ + syslog_level = LOG_INFO; + bb_verror_msg(s, p, NULL); + syslog_level = LOG_ERR; +} + +void FAST_FUNC bb_info_msg(const char *s, ...) +{ + va_list p; + + va_start(p, s); + bb_vinfo_msg(s, p); + va_end(p); +} +#endif -- cgit v1.2.3