logging: Fix holding coherence of log levels in Spinel backend.
LOG_BACKEND_SPINEL_LEVEL turned out to be useless and was removed. Also changes to keep coherence between Zephyr log level and OT log level added by otPlatLog() were introduced. Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
This commit is contained in:
parent
c5d85e175f
commit
b07c2f8463
2 changed files with 23 additions and 28 deletions
|
@ -442,32 +442,6 @@ config LOG_BACKEND_SPINEL_BUFFER_SIZE
|
||||||
help
|
help
|
||||||
Specify reserved size of up-buffer used for logger output.
|
Specify reserved size of up-buffer used for logger output.
|
||||||
|
|
||||||
choice
|
|
||||||
prompt "Spinel backend log level"
|
|
||||||
help
|
|
||||||
This option selects log level for Spinel backend stack.
|
|
||||||
|
|
||||||
config LOG_BACKEND_SPINEL_LEVEL_CRITICAL
|
|
||||||
bool "Critical"
|
|
||||||
config LOG_BACKEND_SPINEL_LEVEL_WARNING
|
|
||||||
bool "Warning"
|
|
||||||
config LOG_BACKEND_SPINEL_LEVEL_NOTE
|
|
||||||
bool "Note"
|
|
||||||
config LOG_BACKEND_SPINEL_LEVEL_INFO
|
|
||||||
bool "Info"
|
|
||||||
config LOG_BACKEND_SPINEL_LEVEL_DEBUG
|
|
||||||
bool "Debug"
|
|
||||||
endchoice
|
|
||||||
|
|
||||||
config LOG_BACKEND_SPINEL_LEVEL
|
|
||||||
int
|
|
||||||
default 1 if LOG_BACKEND_SPINEL_LEVEL_CRITICAL
|
|
||||||
default 2 if LOG_BACKEND_SPINEL_LEVEL_WARNING
|
|
||||||
default 3 if LOG_BACKEND_SPINEL_LEVEL_NOTE
|
|
||||||
default 4 if LOG_BACKEND_SPINEL_LEVEL_INFO
|
|
||||||
default 5 if LOG_BACKEND_SPINEL_LEVEL_DEBUG
|
|
||||||
default 0
|
|
||||||
|
|
||||||
endif # LOG_BACKEND_SPINEL
|
endif # LOG_BACKEND_SPINEL
|
||||||
|
|
||||||
config LOG_BACKEND_NATIVE_POSIX
|
config LOG_BACKEND_NATIVE_POSIX
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
static uint8_t char_buf[CONFIG_LOG_BACKEND_SPINEL_BUFFER_SIZE];
|
static uint8_t char_buf[CONFIG_LOG_BACKEND_SPINEL_BUFFER_SIZE];
|
||||||
static bool panic_mode;
|
static bool panic_mode;
|
||||||
|
static uint16_t last_log_level;
|
||||||
|
|
||||||
static int write(uint8_t *data, size_t length, void *ctx);
|
static int write(uint8_t *data, size_t length, void *ctx);
|
||||||
|
|
||||||
|
@ -33,6 +34,8 @@ static void put(const struct log_backend *const backend,
|
||||||
/* prevent adding CRLF, which may crash spinel decoding */
|
/* prevent adding CRLF, which may crash spinel decoding */
|
||||||
uint32_t flag = LOG_OUTPUT_FLAG_CRLF_NONE;
|
uint32_t flag = LOG_OUTPUT_FLAG_CRLF_NONE;
|
||||||
|
|
||||||
|
last_log_level = msg->hdr.ids.level;
|
||||||
|
|
||||||
log_backend_std_put(&log_output_spinel, flag, msg);
|
log_backend_std_put(&log_output_spinel, flag, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,6 +82,8 @@ static void dropped(const struct log_backend *const backend, uint32_t cnt)
|
||||||
|
|
||||||
static int write(uint8_t *data, size_t length, void *ctx)
|
static int write(uint8_t *data, size_t length, void *ctx)
|
||||||
{
|
{
|
||||||
|
otLogLevel log_level;
|
||||||
|
|
||||||
if (is_panic_mode()) {
|
if (is_panic_mode()) {
|
||||||
/* In panic mode otPlatLog implemented for Spinel protocol
|
/* In panic mode otPlatLog implemented for Spinel protocol
|
||||||
* cannot be used, because it cannot be called from interrupt.
|
* cannot be used, because it cannot be called from interrupt.
|
||||||
|
@ -87,8 +92,24 @@ static int write(uint8_t *data, size_t length, void *ctx)
|
||||||
platformUartPanic();
|
platformUartPanic();
|
||||||
otPlatUartSend(data, length);
|
otPlatUartSend(data, length);
|
||||||
} else {
|
} else {
|
||||||
otPlatLog(CONFIG_LOG_BACKEND_SPINEL_LEVEL,
|
switch (last_log_level) {
|
||||||
OT_LOG_REGION_PLATFORM, "%s", data);
|
case LOG_LEVEL_ERR:
|
||||||
|
log_level = OT_LOG_LEVEL_CRIT;
|
||||||
|
break;
|
||||||
|
case LOG_LEVEL_WRN:
|
||||||
|
log_level = OT_LOG_LEVEL_WARN;
|
||||||
|
break;
|
||||||
|
case LOG_LEVEL_INF:
|
||||||
|
log_level = OT_LOG_LEVEL_INFO;
|
||||||
|
break;
|
||||||
|
case LOG_LEVEL_DBG:
|
||||||
|
log_level = OT_LOG_LEVEL_DEBG;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
log_level = OT_LOG_LEVEL_NONE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
otPlatLog(log_level, OT_LOG_REGION_PLATFORM, "%s", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make sure that buffer will be clean in next attempt */
|
/* make sure that buffer will be clean in next attempt */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue