summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorarmink <[email protected]>2018-11-08 11:23:03 +0800
committerarmink <[email protected]>2018-11-08 11:23:03 +0800
commitc990f0a026d5143c0e73cf8d21a30d60a4a81308 (patch)
tree9d93f028ac0ad51b3b51e2096e5662d4b5849c2b
parent2ff67c932f161dfcb22b68490170477be26f6952 (diff)
[component][ulog] Add tag filter to hexdump function.
-rw-r--r--components/utilities/ulog/ulog.c15
-rw-r--r--components/utilities/ulog/ulog.h2
2 files changed, 11 insertions, 6 deletions
diff --git a/components/utilities/ulog/ulog.c b/components/utilities/ulog/ulog.c
index 54c4c7c264..e7dd665f42 100644
--- a/components/utilities/ulog/ulog.c
+++ b/components/utilities/ulog/ulog.c
@@ -625,17 +625,17 @@ void ulog_raw(const char *format, ...)
/**
* 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 buf hex buffer
* @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 - ' ')
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];
int fmt_result;
@@ -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
/* level filter */
#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;
}
@@ -654,6 +654,11 @@ void ulog_hexdump(const char *name, rt_size_t width, rt_uint8_t *buf, rt_size_t
return;
}
#endif /* ULOG_USING_SYSLOG */
+ else if (!rt_strstr(tag, ulog.filter.tag))
+ {
+ /* tag filter */
+ return;
+ }
#endif /* ULOG_USING_FILTER */
/* get log buffer */
@@ -668,7 +673,7 @@ void ulog_hexdump(const char *name, rt_size_t width, rt_uint8_t *buf, rt_size_t
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, name);
+ log_len += ulog_strcpy(log_len, log_buf + log_len, tag);
log_len += ulog_strcpy(log_len, log_buf + log_len, ": ");
}
else
diff --git a/components/utilities/ulog/ulog.h b/components/utilities/ulog/ulog.h
index ad0525c9a2..ab203602bc 100644
--- a/components/utilities/ulog/ulog.h
+++ b/components/utilities/ulog/ulog.h
@@ -83,7 +83,7 @@ void ulog_async_waiting_log(rt_int32_t time);
/*
* 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.