Skip to content

Commit 8965678

Browse files
committed
console: move to new logger
Use new logger and remove usage of SYS_LOG. Signed-off-by: Anas Nashif <[email protected]>
1 parent 38eea4a commit 8965678

File tree

4 files changed

+30
-58
lines changed

4 files changed

+30
-58
lines changed

drivers/console/Kconfig.telnet

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,9 @@ config TELNET_CONSOLE_PRIO
8484
help
8585
This option helps to fine-tune telnet's inner thread priority.
8686

87-
config SYS_LOG_TELNET_CONSOLE_LEVEL
88-
int "Telnet console log level"
89-
default 0
90-
depends on SYS_LOG
91-
help
92-
Sets log level for telnet console (for telnet console dev only)
93-
94-
Levels are:
95-
96-
- 0 OFF, do not write
97-
98-
- 1 ERROR, only write SYS_LOG_ERR
99-
100-
- 2 WARNING, write SYS_LOG_WRN in addition to previous level
101-
102-
- 3 INFO, write SYS_LOG_INF in addition to previous levels
103-
104-
- 4 DEBUG, write SYS_LOG_DBG in addition to previous levels
87+
module = TELNET_CONSOLE
88+
module-str = telnet console
89+
source "subsys/logging/Kconfig.template.log_config"
10590

10691
config TELNET_CONSOLE_DEBUG_DEEP
10792
bool "Forward output to original console handler"

drivers/console/Kconfig.ws

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,24 +72,9 @@ config WEBSOCKET_CONSOLE_PRIO
7272
help
7373
This option helps to fine-tune WS console inner thread priority.
7474

75-
config SYS_LOG_WEBSOCKET_CONSOLE_LEVEL
76-
int "WS console log level"
77-
default 0
78-
depends on SYS_LOG
79-
help
80-
Sets log level for websocket console (for WS console dev only)
81-
82-
Levels are:
83-
84-
- 0 OFF, do not write
85-
86-
- 1 ERROR, only write SYS_LOG_ERR
87-
88-
- 2 WARNING, write SYS_LOG_WRN in addition to previous level
89-
90-
- 3 INFO, write SYS_LOG_INF in addition to previous levels
91-
92-
- 4 DEBUG, write SYS_LOG_DBG in addition to previous levels
75+
module = WEBSOCKET_CONSOLE
76+
module-str = web socket console
77+
source "subsys/logging/Kconfig.template.log_config"
9378

9479
config WEBSOCKET_CONSOLE_DEBUG_DEEP
9580
bool "Forward output to original console handler"

drivers/console/telnet_console.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
* RFC 854 - https://tools.ietf.org/html/rfc854
1717
*/
1818

19-
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_TELNET_CONSOLE_LEVEL
20-
#define SYS_LOG_DOMAIN "net/telnet"
21-
#include <logging/sys_log.h>
19+
#define LOG_LEVEL CONFIG_TELNET_CONSOLE_LOG_LEVEL
20+
#define LOG_DOMAIN net_telnet
21+
#include <logging/log.h>
22+
LOG_MODULE_REGISTER(LOG_DOMAIN);
2223

2324
#include <zephyr.h>
2425
#include <init.h>
@@ -226,7 +227,7 @@ static void telnet_sent_cb(struct net_context *client,
226227
{
227228
if (status) {
228229
telnet_end_client_connection();
229-
SYS_LOG_ERR("Could not sent last packet");
230+
LOG_ERR("Could not sent last packet");
230231
}
231232
}
232233

@@ -313,7 +314,7 @@ static inline void telnet_reply_command(void)
313314
telnet_reply_do_command();
314315
break;
315316
default:
316-
SYS_LOG_DBG("Operation %u not handled",
317+
LOG_DBG("Operation %u not handled",
317318
telnet_cmd.op);
318319
break;
319320
}
@@ -340,7 +341,7 @@ static inline bool telnet_handle_command(struct net_pkt *pkt)
340341
#ifdef CONFIG_TELNET_CONSOLE_SUPPORT_COMMAND
341342
cmd = (struct telnet_simple_command *)l_start;
342343

343-
SYS_LOG_DBG("Got a command %u/%u/%u", cmd->iac, cmd->op, cmd->opt);
344+
LOG_DBG("Got a command %u/%u/%u", cmd->iac, cmd->op, cmd->opt);
344345

345346
if (!k_sem_take(&cmd_lock, K_NO_WAIT)) {
346347
telnet_command_cpy(&telnet_cmd, cmd);
@@ -401,7 +402,7 @@ static void telnet_recv(struct net_context *client,
401402
if (!pkt || status) {
402403
telnet_end_client_connection();
403404

404-
SYS_LOG_DBG("Telnet client dropped (AF_INET%s) status %d",
405+
LOG_DBG("Telnet client dropped (AF_INET%s) status %d",
405406
net_context_get_family(client) == AF_INET ?
406407
"" : "6", status);
407408
return;
@@ -433,17 +434,17 @@ static void telnet_accept(struct net_context *client,
433434
void *user_data)
434435
{
435436
if (error) {
436-
SYS_LOG_ERR("Error %d", error);
437+
LOG_ERR("Error %d", error);
437438
goto error;
438439
}
439440

440441
if (client_cnx) {
441-
SYS_LOG_WRN("A telnet client is already in.");
442+
LOG_WRN("A telnet client is already in.");
442443
goto error;
443444
}
444445

445446
if (net_context_recv(client, telnet_recv, 0, NULL)) {
446-
SYS_LOG_ERR("Unable to setup reception (family %u)",
447+
LOG_ERR("Unable to setup reception (family %u)",
447448
net_context_get_family(client));
448449
goto error;
449450
}
@@ -452,7 +453,7 @@ static void telnet_accept(struct net_context *client,
452453
goto error;
453454
}
454455

455-
SYS_LOG_DBG("Telnet client connected (family AF_INET%s)",
456+
LOG_DBG("Telnet client connected (family AF_INET%s)",
456457
net_context_get_family(client) == AF_INET ? "" : "6");
457458

458459
orig_printk_hook = __printk_get_hook();
@@ -470,32 +471,32 @@ static void telnet_setup_server(struct net_context **ctx, sa_family_t family,
470471
struct sockaddr *addr, socklen_t addrlen)
471472
{
472473
if (net_context_get(family, SOCK_STREAM, IPPROTO_TCP, ctx)) {
473-
SYS_LOG_ERR("No context available");
474+
LOG_ERR("No context available");
474475
goto error;
475476
}
476477

477478
if (net_context_bind(*ctx, addr, addrlen)) {
478-
SYS_LOG_ERR("Cannot bind on family AF_INET%s",
479+
LOG_ERR("Cannot bind on family AF_INET%s",
479480
family == AF_INET ? "" : "6");
480481
goto error;
481482
}
482483

483484
if (net_context_listen(*ctx, 0)) {
484-
SYS_LOG_ERR("Cannot listen on");
485+
LOG_ERR("Cannot listen on");
485486
goto error;
486487
}
487488

488489
if (net_context_accept(*ctx, telnet_accept, K_NO_WAIT, NULL)) {
489-
SYS_LOG_ERR("Cannot accept");
490+
LOG_ERR("Cannot accept");
490491
goto error;
491492
}
492493

493-
SYS_LOG_DBG("Telnet console enabled on AF_INET%s",
494+
LOG_DBG("Telnet console enabled on AF_INET%s",
494495
family == AF_INET ? "" : "6");
495496

496497
return;
497498
error:
498-
SYS_LOG_ERR("Unable to start telnet on AF_INET%s",
499+
LOG_ERR("Unable to start telnet on AF_INET%s",
499500
family == AF_INET ? "" : "6");
500501

501502
if (*ctx) {
@@ -549,7 +550,7 @@ static int telnet_console_init(struct device *arg)
549550
NULL, NULL, NULL,
550551
K_PRIO_COOP(TELNET_PRIORITY), 0, K_MSEC(10));
551552

552-
SYS_LOG_INF("Telnet console initialized");
553+
LOG_INF("Telnet console initialized");
553554

554555
return 0;
555556
}

drivers/console/websocket_console.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
* a websocket connection.
1414
*/
1515

16-
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_WEBSOCKET_CONSOLE_LEVEL
17-
#define SYS_LOG_DOMAIN "ws/console"
18-
#include <logging/sys_log.h>
16+
#define LOG_LEVEL CONFIG_WEBSOCKET_CONSOLE_LOG_LEVEL
17+
#define LOG_DOMAIN ws_console
18+
#include <logging/log.h>
19+
LOG_MODULE_REGISTER(LOG_DOMAIN);
1920

2021
#include <zephyr.h>
2122
#include <init.h>
@@ -328,7 +329,7 @@ static int ws_console_init(struct device *arg)
328329
NULL, NULL, NULL,
329330
K_PRIO_COOP(WS_CONSOLE_PRIORITY), 0, K_MSEC(10));
330331

331-
SYS_LOG_INF("Websocket console initialized");
332+
LOG_INF("Websocket console initialized");
332333

333334
return 0;
334335
}

0 commit comments

Comments
 (0)