启用 ulog 并适配 elog 接口

Signed-off-by: a1012112796 <1012112796@qq.com>
This commit is contained in:
2022-12-17 08:57:35 +08:00
parent e9b743dbb8
commit 3fd2f3ccce
5 changed files with 78 additions and 2 deletions

View File

@@ -648,6 +648,31 @@ void ulog_voutput(rt_uint32_t level, const char *tag, rt_bool_t newline, const c
output_unlock();
}
static const uint32_t elog_leves[] =
{
LOG_LVL_ASSERT, // ELOG_LVL_ASSERT 0
LOG_LVL_ERROR, // ELOG_LVL_ERROR 1
LOG_LVL_WARNING, // ELOG_LVL_WARN 2
LOG_LVL_INFO, // ELOG_LVL_INFO 3
LOG_LVL_DBG, // ELOG_LVL_DEBUG 4
LOG_LVL_DBG, // ELOG_LVL_VERBOSE 5
};
void elog_output(uint8_t level, const char *tag, const char *file, const char *func,
const long line, const char *format, ...)
{
va_list args;
static char line_buffer[256] = {0};
rt_snprintf(line_buffer, sizeof(line_buffer), "[%s:%s:%d] %s", file, func, line, format);
/* args point to the first variable parameter */
va_start(args, format);
ulog_voutput(elog_leves[level], tag, RT_TRUE, line_buffer, args);
va_end(args);
}
/**
* output the log
*