drivers: slip: Rework logging to follow conventions
Previously, there was boolean CONFIG_SLIP_DEBUG, which effectively
switched between "logging off" and "debug-level logging". Instead,
switch to CONFIG_SYS_LOG_SLIP_LEVEL (the naming of the option follows
existing conventions) which allows to select any of the standard 5
logging levels.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
diff --git a/drivers/slip/Kconfig b/drivers/slip/Kconfig
index 23099f9..a152052 100644
--- a/drivers/slip/Kconfig
+++ b/drivers/slip/Kconfig
@@ -57,11 +57,20 @@
data into net_buf's. The actual SLIP connection
does not use this value.
-config SLIP_DEBUG
- bool "SLIP driver debug"
- default n
+config SYS_LOG_SLIP_LEVEL
+ int
+ prompt "SLIP driver log level"
+ depends on SYS_LOG && SLIP
+ default 0
+ range 0 4
help
- This option enables debug support for SLIP driver.
+ Sets log level for SLIP driver.
+ Levels are:
+ 0 OFF, do not write
+ 1 ERROR, only write SYS_LOG_ERR
+ 2 WARNING, write SYS_LOG_WRN in addition to previous level
+ 3 INFO, write SYS_LOG_INF in addition to previous levels
+ 4 DEBUG, write SYS_LOG_DBG in addition to previous levels
config SLIP_STATISTICS
bool "SLIP network connection statistics"
diff --git a/drivers/slip/slip.c b/drivers/slip/slip.c
index 238d954..0c3d749 100644
--- a/drivers/slip/slip.c
+++ b/drivers/slip/slip.c
@@ -11,13 +11,10 @@
* host and qemu. The host will need to run tunslip process.
*/
-
-#if defined(CONFIG_SLIP_DEBUG)
#define SYS_LOG_DOMAIN "slip"
-#define SYS_LOG_LEVEL SYS_LOG_LEVEL_DEBUG
+#define SYS_LOG_LEVEL CONFIG_SYS_LOG_SLIP_LEVEL
#include <logging/sys_log.h>
#include <stdio.h>
-#endif
#include <kernel.h>
@@ -65,7 +62,7 @@
#endif
};
-#if defined(CONFIG_SLIP_DEBUG)
+#if SYS_LOG_LEVEL >= SYS_LOG_LEVEL_DEBUG
#if defined(CONFIG_SYS_LOG_SHOW_COLOR)
#define COLOR_OFF "\x1B[0m"
#define COLOR_YELLOW "\x1B[0;33m"
@@ -178,7 +175,7 @@
slip_writeb(SLIP_END);
for (frag = pkt->frags; frag; frag = frag->frags) {
-#if defined(CONFIG_SLIP_DEBUG)
+#if SYS_LOG_LEVEL >= SYS_LOG_LEVEL_DEBUG
int frag_count = 0;
#endif
@@ -211,7 +208,7 @@
slip_writeb_esc(c);
}
-#if defined(CONFIG_SLIP_DEBUG)
+#if SYS_LOG_LEVEL >= SYS_LOG_LEVEL_DEBUG
SYS_LOG_DBG("sent data %d bytes",
frag->len + net_pkt_ll_reserve(pkt));
if (frag->len + ll_reserve) {
@@ -385,7 +382,7 @@
for (i = 0; i < *off; i++) {
if (slip_input_byte(slip, buf[i])) {
-#if defined(CONFIG_SLIP_DEBUG)
+#if SYS_LOG_LEVEL >= SYS_LOG_LEVEL_DEBUG
struct net_buf *frag = slip->rx->frags;
int bytes = net_buf_frags_len(frag);
int count = 0;
diff --git a/samples/net/dhcpv4_client/prj.conf b/samples/net/dhcpv4_client/prj.conf
index 729dcea..c26959b 100644
--- a/samples/net/dhcpv4_client/prj.conf
+++ b/samples/net/dhcpv4_client/prj.conf
@@ -31,5 +31,4 @@
CONFIG_NET_DEBUG_ARP=n
CONFIG_NET_DEBUG_L2_ETHERNET=n
-CONFIG_SLIP_DEBUG=n
CONFIG_SLIP_STATISTICS=n