提交 c990f0a0 编写于 作者: armink_ztl's avatar armink_ztl

[component][ulog] Add tag filter to hexdump function.

上级 2ff67c93
...@@ -625,17 +625,17 @@ void ulog_raw(const char *format, ...) ...@@ -625,17 +625,17 @@ void ulog_raw(const char *format, ...)
/** /**
* dump the hex format data to log * dump the hex format data to log
* *
* @param name name for hex object, it will show on log header * @param tag name for hex object, it will show on log header
* @param width hex number for every line, such as: 16, 32 * @param width hex number for every line, such as: 16, 32
* @param buf hex buffer * @param buf hex buffer
* @param size buffer size * @param size buffer size
*/ */
void ulog_hexdump(const char *name, rt_size_t width, rt_uint8_t *buf, rt_size_t size) void ulog_hexdump(const char *tag, rt_size_t width, rt_uint8_t *buf, rt_size_t size)
{ {
#define __is_print(ch) ((unsigned int)((ch) - ' ') < 127u - ' ') #define __is_print(ch) ((unsigned int)((ch) - ' ') < 127u - ' ')
rt_size_t i, j; rt_size_t i, j;
rt_size_t log_len = 0, name_len = rt_strlen(name); rt_size_t log_len = 0, name_len = rt_strlen(tag);
char *log_buf = NULL, dump_string[8]; char *log_buf = NULL, dump_string[8];
int fmt_result; int fmt_result;
...@@ -644,7 +644,7 @@ void ulog_hexdump(const char *name, rt_size_t width, rt_uint8_t *buf, rt_size_t ...@@ -644,7 +644,7 @@ void ulog_hexdump(const char *name, rt_size_t width, rt_uint8_t *buf, rt_size_t
#ifdef ULOG_USING_FILTER #ifdef ULOG_USING_FILTER
/* level filter */ /* level filter */
#ifndef ULOG_USING_SYSLOG #ifndef ULOG_USING_SYSLOG
if (LOG_LVL_DBG > ulog.filter.level) if (LOG_LVL_DBG > ulog.filter.level || LOG_LVL_DBG > ulog_tag_lvl_filter_get(tag))
{ {
return; return;
} }
...@@ -654,6 +654,11 @@ void ulog_hexdump(const char *name, rt_size_t width, rt_uint8_t *buf, rt_size_t ...@@ -654,6 +654,11 @@ void ulog_hexdump(const char *name, rt_size_t width, rt_uint8_t *buf, rt_size_t
return; return;
} }
#endif /* ULOG_USING_SYSLOG */ #endif /* ULOG_USING_SYSLOG */
else if (!rt_strstr(tag, ulog.filter.tag))
{
/* tag filter */
return;
}
#endif /* ULOG_USING_FILTER */ #endif /* ULOG_USING_FILTER */
/* get log buffer */ /* get log buffer */
...@@ -668,7 +673,7 @@ void ulog_hexdump(const char *name, rt_size_t width, rt_uint8_t *buf, rt_size_t ...@@ -668,7 +673,7 @@ void ulog_hexdump(const char *name, rt_size_t width, rt_uint8_t *buf, rt_size_t
if (i == 0) if (i == 0)
{ {
log_len += ulog_strcpy(log_len, log_buf + log_len, "D/HEX "); log_len += ulog_strcpy(log_len, log_buf + log_len, "D/HEX ");
log_len += ulog_strcpy(log_len, log_buf + log_len, name); log_len += ulog_strcpy(log_len, log_buf + log_len, tag);
log_len += ulog_strcpy(log_len, log_buf + log_len, ": "); log_len += ulog_strcpy(log_len, log_buf + log_len, ": ");
} }
else else
......
...@@ -83,7 +83,7 @@ void ulog_async_waiting_log(rt_int32_t time); ...@@ -83,7 +83,7 @@ void ulog_async_waiting_log(rt_int32_t time);
/* /*
* dump the hex format data to log * dump the hex format data to log
*/ */
void ulog_hexdump(const char *name, rt_size_t width, rt_uint8_t *buf, rt_size_t size); void ulog_hexdump(const char *tag, rt_size_t width, rt_uint8_t *buf, rt_size_t size);
/* /*
* Another log output API. This API is more difficult to use than LOG_X API. * Another log output API. This API is more difficult to use than LOG_X API.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册