Skip to content

Commit

Permalink
[nrf fromtree] openthread: fix logging configuration
Browse files Browse the repository at this point in the history
Currently, `CONFIG_OPENTHREAD_LOG_LEVEL` is used to set log level
in OT and register log modules in Zephyr. OpenThread allows 5
levels, causing issues when `OPENTHREAD_LOG_LEVEL_DEBG` is
selected ad we are trying to register modules with unknown lvl.

This commit adds `CONFIG_OPENTHREAD_MODULE_LOG_LEVEL` which is
aligned for Zephyr's log levels.

Signed-off-by: Maciej Baczmanski <[email protected]>
(cherry picked from commit 341359568fdbaa217d8c1f71064e97af985a867f)
  • Loading branch information
maciejbaczmanski authored and rlubos committed Jan 31, 2025
1 parent 2d1e173 commit 471e0a9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/openthread/platform/alarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

#define LOG_MODULE_NAME net_openthread_alarm
#define LOG_LEVEL CONFIG_OPENTHREAD_LOG_LEVEL
#define LOG_LEVEL CONFIG_OPENTHREAD_PLATFORM_LOG_LEVEL

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(LOG_MODULE_NAME);
Expand Down
2 changes: 1 addition & 1 deletion modules/openthread/platform/ble.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/* Zephyr Logging */

#define LOG_MODULE_NAME net_openthread_tcat
#define LOG_LEVEL CONFIG_OPENTHREAD_LOG_LEVEL
#define LOG_LEVEL CONFIG_OPENTHREAD_PLATFORM_LOG_LEVEL

LOG_MODULE_REGISTER(LOG_MODULE_NAME);

Expand Down
2 changes: 1 addition & 1 deletion modules/openthread/platform/messagepool.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <openthread/platform/messagepool.h>

#define LOG_MODULE_NAME net_otPlat_messagepool
#define LOG_LEVEL CONFIG_OPENTHREAD_LOG_LEVEL
#define LOG_LEVEL CONFIG_OPENTHREAD_PLATFORM_LOG_LEVEL

LOG_MODULE_REGISTER(LOG_MODULE_NAME);

Expand Down
2 changes: 1 addition & 1 deletion modules/openthread/platform/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

#define LOG_LEVEL CONFIG_OPENTHREAD_LOG_LEVEL
#define LOG_LEVEL CONFIG_OPENTHREAD_PLATFORM_LOG_LEVEL
#define LOG_MODULE_NAME net_otPlat_uart

#include <zephyr/logging/log.h>
Expand Down
12 changes: 12 additions & 0 deletions subsys/net/l2/openthread/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ config OPENTHREAD_LOG_LEVEL
default 4 if OPENTHREAD_LOG_LEVEL_INFO
default 5 if OPENTHREAD_LOG_LEVEL_DEBG
default 0
help
Log level for OpenThread stack.

config OPENTHREAD_PLATFORM_LOG_LEVEL
int
default 1 if OPENTHREAD_LOG_LEVEL_CRIT
default 2 if OPENTHREAD_LOG_LEVEL_WARN
default 3 if OPENTHREAD_LOG_LEVEL_NOTE || OPENTHREAD_LOG_LEVEL_INFO
default 4 if OPENTHREAD_LOG_LEVEL_DEBG
default 0
help
Log level for OpenThread Zephyr platform.

menuconfig OPENTHREAD_L2_DEBUG
bool "OpenThread L2 log support"
Expand Down

0 comments on commit 471e0a9

Please sign in to comment.