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>
This commit is contained in:
James Byrne
2019-04-12 17:01:51 +00:00
committed by Denys Vlasenko
parent f3a064f495
commit 253c4e787a
20 changed files with 130 additions and 99 deletions

View File

@@ -326,7 +326,7 @@ static int run_script(const char *action)
char *argv[5];
int r;
bb_error_msg("executing '%s %s %s'", G.script_name, G.iface, action);
bb_info_msg("executing '%s %s %s'", G.script_name, G.iface, action);
argv[0] = (char*) G.script_name;
argv[1] = (char*) G.iface;
@@ -345,7 +345,7 @@ static int run_script(const char *action)
bb_unsetenv_and_free(env_PREVIOUS);
bb_unsetenv_and_free(env_CURRENT);
bb_error_msg("exit code: %d", r & 0xff);
bb_info_msg("exit code: %d", r & 0xff);
return (option_mask32 & FLAG_IGNORE_RETVAL) ? 0 : r;
}
@@ -365,7 +365,7 @@ static void up_iface(void)
if (!(ifrequest.ifr_flags & IFF_UP)) {
ifrequest.ifr_flags |= IFF_UP;
/* Let user know we mess up with interface */
bb_error_msg("upping interface");
bb_info_msg("upping interface");
if (network_ioctl(SIOCSIFFLAGS, &ifrequest, "setting interface flags") < 0) {
if (errno != ENODEV && errno != EADDRNOTAVAIL)
xfunc_die();
@@ -414,7 +414,7 @@ static void maybe_up_new_iface(void)
(uint8_t)(ifrequest.ifr_hwaddr.sa_data[5]));
}
bb_error_msg("using interface %s%s with driver<%s> (version: %s)",
bb_info_msg("using interface %s%s with driver<%s> (version: %s)",
G.iface, buf, driver_info.driver, driver_info.version);
}
#endif
@@ -447,7 +447,7 @@ static smallint detect_link(void)
logmode = sv_logmode;
if (status != IFSTATUS_ERR) {
G.api_method_num = i;
bb_error_msg("using %s detection mode", method_table[i].name);
bb_info_msg("using %s detection mode", method_table[i].name);
break;
}
}
@@ -632,7 +632,7 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv)
/* | (1 << SIGCHLD) - run_script does not use it anymore */
, record_signo);
bb_error_msg("started: %s", bb_banner);
bb_info_msg("started: %s", bb_banner);
if (opts & FLAG_MONITOR) {
struct ifreq ifrequest;
@@ -649,7 +649,7 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv)
iface_status_str = strstatus(iface_status);
if (opts & FLAG_MONITOR) {
bb_error_msg("interface %s",
bb_info_msg("interface %s",
G.iface_exists ? "exists"
: "doesn't exist, waiting");
}
@@ -657,7 +657,7 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv)
* by potentially lying that it really exists */
if (G.iface_exists) {
bb_error_msg("link is %s", iface_status_str);
bb_info_msg("link is %s", iface_status_str);
}
if ((!(opts & FLAG_NO_STARTUP)
@@ -712,7 +712,7 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv)
if (G.iface_exists < 0) /* error */
goto exiting;
if (iface_exists_old != G.iface_exists) {
bb_error_msg("interface %sappeared",
bb_info_msg("interface %sappeared",
G.iface_exists ? "" : "dis");
if (G.iface_exists)
maybe_up_new_iface();
@@ -730,7 +730,7 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv)
iface_status_str = strstatus(iface_status);
if (iface_status_old != iface_status) {
bb_error_msg("link is %s", iface_status_str);
bb_info_msg("link is %s", iface_status_str);
if (delay_time) {
/* link restored its old status before