Commit b4f563ae authored by Adam Wujek's avatar Adam Wujek 💬

[FEATURE: 1417] Kconfig: add verbosity config items for userspace programs

Until now configuration items like WRS_LOG_HAL could change only loglevel of
syslog messages, not the verbosity of the program.

Please note that all messages produced by programs if syslog is
configured will be passed to the syslog at the same <facility>.<level>
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 5e52d339
......@@ -224,6 +224,26 @@ config WRS_LOG_HAL
spefification like "daemon.debug". An empty strings is used
to represent no logging (like /dev/null). Please note that
unknown facility names will generate a runtime error on the switch.
Please note that all messages produced by the WR HAL if syslog is
configured will be passed to the syslog at the same
<facility>.<level>, no matter of verbosity of a message.
config WRS_LOG_LEVEL_HAL
string "Logging verbosity level for the WR HAL"
default ""
help
Specify verbosity of WR HAL as a string or number. The following
levels are supported:
ALERT (1)
ERROR (3)
WARNING (4)
INFO (6)
DEBUG (7)
By leaving this item empty, HAL will use its default verbosity level
(INFO).
Please note that all messages produced by the WR HAL if syslog is
configured will be passed to the syslog at the same
<facility>.<level>, no matter of verbosity of a message.
config WRS_LOG_RTU
string "Logging directions for the RTU daemon"
......@@ -233,15 +253,51 @@ config WRS_LOG_RTU
spefification like "daemon.debug". An empty strings is used
to represent no logging (like /dev/null). Please note that
unknown facility names will generate a runtime error on the switch.
Please note that all messages produced by RTU daemon if syslog is
configured will be passed to the syslog at the same
<facility>.<level>, no matter of verbosity of a message.
config WRS_LOG_LEVEL_RTU
string "Logging verbosity level for the RTU daemon"
default ""
help
Specify verbosity of RTU daemon as a string or number. The following
levels are supported:
ALERT (1)
ERROR (3)
WARNING (4)
INFO (6)
DEBUG (7)
By leaving this item empty, RTU daemon will use its default verbosity
level (INFO).
Please note that all messages produced by RTU daemon if syslog is
configured will be passed to the syslog at the same
<facility>.<level>, no matter of verbosity of a message.
config WRS_LOG_PTP
string "Logging directions for the PTP server (ptpd or ppsi)"
string "Logging directions for the PTP server (ppsi)"
default "daemon.info"
help
The string can be a pathname (e.g. /dev/kmsg) or a <facility>.<level>
spefification like "daemon.debug". An empty strings is used
to represent no logging (like /dev/null). Please note that
unknown facility names will generate a runtime error on the switch.
Please note that all messages produced by PPSi if syslog is
configured will be passed to the syslog at the same
<facility>.<level>, no matter of verbosity of a message.
config WRS_LOG_LEVEL_PTP
string "Logging verbosity level for the PTP server (ppsi)"
default ""
help
Specify verbosity of PPSi daemon as a string. This string will be
passed to the PPSI after "-d" parameter. Please refer to the PPSI's
documentation for more details.
By leaving this item empty, PPSi daemon will use its default
verbosity level.
Please note that all messages produced by PPSi if syslog is
configured will be passed to the syslog at the same
<facility>.<level>, no matter of verbosity of a message.
config WRS_LOG_SNMPD
string "Logging directions for the SNMP daemon"
......@@ -283,6 +339,23 @@ config WRS_LOG_OTHER
to represent no logging (like /dev/null). Please note that
unknown facility names will generate a runtime error on the switch.
config WRS_LOG_LEVEL_OTHER
string "Logging verbosity level for other programs"
default ""
help
Specify verbosity of other programs as a string or number. The
following levels are supported:
ALERT (1)
ERROR (3)
WARNING (4)
INFO (6)
DEBUG (7)
By leaving this item empty, other programs daemon will use their
default verbosity level (INFO).
Please note that all messages produced by other programs if syslog is
configured will be passed to the syslog at the same
<facility>.<level>
config KEEP_ROOTFS
bool "Keep generated filesystem and related script"
help
......
......@@ -622,6 +622,47 @@ appropriate way, before the respective service is started.
unknown facility names will generate a runtime error on the switch.
All four strings default to ``@t{daemon.info}''.
@b{Note:} all messages produced by these programs if syslog is
configured will be passed to the syslog at the same
configured @i{<facility>.<level>}, no matter of verbosity of a message.
To change the verbosity of programs please use
@t{CONFIG_WRS_LOG_LEVEL_*}.
@item CONFIG_WRS_LOG_LEVEL_HAL
@itemx CONFIG_WRS_LOG_LEVEL_RTU
@itemx CONFIG_WRS_LOG_LEVEL_OTHER
Specify verbosity of programs as a string or number. The following
levels are supported:
@itemize
@item @t{ALERT} or 1
@item @t{ERROR} or 3
@item @t{WARNING} or 4
@item @t{INFO} or 6
@item @t{DEBUG} or 7
@end itemize
Not supported levels are ceiled to the valid one.
By leaving this item empty, programs will use its default verbosity
level (@t{INFO}).
@b{Note:} all messages produced by these programs if syslog is
configured will be passed to the syslog at the same
configured @i{<facility>.<level>}, no matter of verbosity of a message.
@item CONFIG_WRS_LOG_LEVEL_PTP
Specify verbosity of PPSi daemon as a string. This string will be
passed to the PPSI after @t{-d} parameter. Please refer to the PPSI's
documentation for more details.
By leaving this item empty, PPSi daemon will use its default
verbosity level.
@b{Note:} all messages produced by PPSi if syslog is
configured will be passed to the syslog at the same
configured @i{<facility>.<level>}, no matter of verbosity of a message.
@item CONFIG_WRS_LOG_SNMPD
Value can be a pathname, either to a file (e.g.
......
......@@ -18,10 +18,10 @@ int wrs_msg_level = WRS_MSG_DEFAULT_LEVEL;
/* We use debug, info, warning, error and "silent" */
static int wrs_msg_used_levels[] = {
LOG_ALERT, /* more silent then ERR, but "1" not 0 */
LOG_ERR,
LOG_WARNING,
LOG_INFO,
LOG_DEBUG,
LOG_ERR, /* 3 */
LOG_WARNING, /* 4 */
LOG_INFO, /* 6 */
LOG_DEBUG, /* 7 */
};
static int wrs_msg_pos;
......@@ -45,15 +45,63 @@ void wrs_msg_init(int argc, char **argv)
int i;
int max = ARRAY_SIZE(wrs_msg_used_levels) - 1;
char *e;
char *endptr = NULL;
prgname = argv[0];
wrs_msg_f = stderr;
e = getenv("WRS_MSG_LEVEL");
if (e) {
i = atoi(e);
if (i) /* not 0 (EMERG) as atoi returns 0 on error */
if (e && *e != '\0') {
i = strtol(e, &endptr, 0);
if (*endptr == '\0') {
wrs_msg_level = i;
} else {
/* check log levels even we dont't support them */
if (!strcmp(e, "LOG_EMERG")
|| !strcmp(e, "EMERG")
|| !strcmp(e, "emerg"))
wrs_msg_level = LOG_EMERG;
else if (!strcmp(e, "LOG_ALERT")
|| !strcmp(e, "ALERT")
|| !strcmp(e, "alert"))
wrs_msg_level = LOG_ALERT;
else if (!strcmp(e, "LOG_CRIT")
|| !strcmp(e, "CRIT")
|| !strcmp(e, "crit")
)
wrs_msg_level = LOG_CRIT;
else if (!strcmp(e, "LOG_ERR")
|| !strcmp(e, "ERR")
|| !strcmp(e, "err")
|| !strcmp(e, "LOG_ERROR")
|| !strcmp(e, "ERROR")
|| !strcmp(e, "error")
)
wrs_msg_level = LOG_ERR;
else if (!strcmp(e, "LOG_WARNING")
|| !strcmp(e, "WARNING")
|| !strcmp(e, "warning")
|| !strcmp(e, "LOG_WAR")
|| !strcmp(e, "WARN")
|| !strcmp(e, "warn")
)
wrs_msg_level = LOG_WARNING;
else if (!strcmp(e, "LOG_NOTICE")
|| !strcmp(e, "NOTICE")
|| !strcmp(e, "notice"))
wrs_msg_level = LOG_NOTICE;
else if (!strcmp(e, "LOG_INFO")
|| !strcmp(e, "INFO")
|| !strcmp(e, "info"))
wrs_msg_level = LOG_INFO;
else if (!strcmp(e, "LOG_DEBUG")
|| !strcmp(e, "DEBUG")
|| !strcmp(e, "debug"))
wrs_msg_level = LOG_DEBUG;
else
pr_error("Wrong value \"%s\" in variable "
"WRS_MSG_LEVEL\n", e);
}
}
/* Start at this level, then scan for individual "-v" or "-q" */
......
......@@ -17,7 +17,6 @@ start() {
if [ -z $WRS_LOG ]; then
WRS_LOG="/dev/null";
fi
# if a pathname, use it
if echo "$WRS_LOG" | grep / > /dev/null; then
eval LOGPIPE=\" \> $WRS_LOG 2\>\&1 \";
......@@ -26,7 +25,14 @@ start() {
eval LOGPIPE=\" 2\>\&1 \| logger -t wr-switch -p $WRS_LOG\"
fi
# be carefull with pidof, no running script should have the same name as process
# set msg level
if [ ! -z $CONFIG_WRS_LOG_LEVEL_HAL ]; then
WRS_MSG_LEVEL=$CONFIG_WRS_LOG_LEVEL_HAL
export WRS_MSG_LEVEL
fi
# be carefull with pidof, no running script should have the same name as
# process
if pidof wrsw_hal > /dev/null; then
# wrsw_hal already running
echo "Failed (already running?)"
......
......@@ -18,6 +18,11 @@ start() {
WRS_LOG="/dev/null";
fi
# set msg level
if [ ! -z $CONFIG_WRS_LOG_LEVEL_PTP ]; then
LOG_LEVEL="-d $CONFIG_WRS_LOG_LEVEL_PTP"
fi
# if a pathname, use it
if echo "$WRS_LOG" | grep / > /dev/null; then
eval LOGPIPE=\" \> $WRS_LOG 2\>\&1 \";
......@@ -31,7 +36,7 @@ start() {
# ppsi already running
echo "Failed (already running?)"
else
eval /wr/bin/ppsi $LOGPIPE \&
eval /wr/bin/ppsi $LOG_LEVEL $LOGPIPE \&
echo "OK"
fi
}
......
......@@ -26,7 +26,14 @@ start() {
eval LOGPIPE=\" 2\>\&1 \| logger -t wr-switch -p $WRS_LOG\"
fi
# be carefull with pidof, no running script should have the same name as process
# set msg level
if [ ! -z $CONFIG_WRS_LOG_LEVEL_RTU ]; then
WRS_MSG_LEVEL=$CONFIG_WRS_LOG_LEVEL_RTU
export WRS_MSG_LEVEL
fi
# be carefull with pidof, no running script should have the same name as
# process
if pidof rtud > /dev/null; then
# rtud already running
echo "Failed (already running?)"
......
......@@ -33,6 +33,12 @@ start() {
eval LOGPIPE=\" 2\>\&1 \| logger -t wr-switch -p $WRS_LOG\"
fi
# set msg level
if [ ! -z $CONFIG_WRS_LOG_LEVEL_OTHER ]; then
WRS_MSG_LEVEL=$CONFIG_WRS_LOG_LEVEL_OTHER
export WRS_MSG_LEVEL
fi
# set-up VLANs
eval /wr/bin/wrs_vlans -f /wr/etc/dot-config $LOGPIPE
ret=$?
......
......@@ -38,6 +38,12 @@ start() {
eval LOGPIPE=\" 2\>\&1 \| logger -t wr-switch -p $WRS_LOG\"
fi
# set msg level
if [ ! -z $CONFIG_WRS_LOG_LEVEL_OTHER ]; then
WRS_MSG_LEVEL=$CONFIG_WRS_LOG_LEVEL_OTHER
export WRS_MSG_LEVEL
fi
# If custom boot script is not enabled, exit
if [ ! "$CONFIG_CUSTOM_BOOT_SCRIPT_ENABLED" = "y" ]; then
echo "disabled"
......
......@@ -43,6 +43,12 @@ start() {
eval LOGPIPE=\" 2\>\&1 \| logger -t wr-switch -p $WRS_LOG\"
fi
# set msg level
if [ ! -z $CONFIG_WRS_LOG_LEVEL_OTHER ]; then
WRS_MSG_LEVEL=$CONFIG_WRS_LOG_LEVEL_OTHER
export WRS_MSG_LEVEL
fi
eval /wr/bin/wrs_watchdog -d -p $WDG_PID $LOGPIPE \&
start_counter
echo "OK"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment