1 /*
2 * Copyright (c) 2018 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include "ext_log_system_adapter.h"
8 #include "ext_log_system.h"
9
10 #define LOG_MODULE_NAME ext_log_system
11 #include <zephyr/logging/log.h>
12
13 LOG_MODULE_REGISTER(ext_log_system);
14
15 /** @brief Translation of custom log levels to logging subsystem levels. */
16 static const uint8_t log_level_lut[] = {
17 LOG_LEVEL_ERR, /* EXT_LOG_CRITICAL */
18 LOG_LEVEL_ERR, /* EXT_LOG_ERROR */
19 LOG_LEVEL_WRN, /* EXT_LOG_WARNING */
20 LOG_LEVEL_INF, /* EXT_LOG_NOTICE */
21 LOG_LEVEL_INF, /* EXT_LOG_INFO */
22 LOG_LEVEL_DBG /* EXT_LOG_DEBUG */
23 };
24
log_handler(enum ext_log_level level,const char * fmt,...)25 static void log_handler(enum ext_log_level level, const char *fmt, ...)
26 {
27 va_list ap;
28
29 va_start(ap, fmt);
30 log_generic(log_level_lut[level], fmt, ap);
31 va_end(ap);
32 }
33
ext_log_system_log_adapt(void)34 void ext_log_system_log_adapt(void)
35 {
36 ext_log_handler_set(log_handler);
37 }
38