Skip to content

Commit c990f0a

Browse files
committed
[component][ulog] Add tag filter to hexdump function.
1 parent 2ff67c9 commit c990f0a

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

components/utilities/ulog/ulog.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -625,17 +625,17 @@ void ulog_raw(const char *format, ...)
625625
/**
626626
* dump the hex format data to log
627627
*
628-
* @param name name for hex object, it will show on log header
628+
* @param tag name for hex object, it will show on log header
629629
* @param width hex number for every line, such as: 16, 32
630630
* @param buf hex buffer
631631
* @param size buffer size
632632
*/
633-
void ulog_hexdump(const char *name, rt_size_t width, rt_uint8_t *buf, rt_size_t size)
633+
void ulog_hexdump(const char *tag, rt_size_t width, rt_uint8_t *buf, rt_size_t size)
634634
{
635635
#define __is_print(ch) ((unsigned int)((ch) - ' ') < 127u - ' ')
636636

637637
rt_size_t i, j;
638-
rt_size_t log_len = 0, name_len = rt_strlen(name);
638+
rt_size_t log_len = 0, name_len = rt_strlen(tag);
639639
char *log_buf = NULL, dump_string[8];
640640
int fmt_result;
641641

@@ -644,7 +644,7 @@ void ulog_hexdump(const char *name, rt_size_t width, rt_uint8_t *buf, rt_size_t
644644
#ifdef ULOG_USING_FILTER
645645
/* level filter */
646646
#ifndef ULOG_USING_SYSLOG
647-
if (LOG_LVL_DBG > ulog.filter.level)
647+
if (LOG_LVL_DBG > ulog.filter.level || LOG_LVL_DBG > ulog_tag_lvl_filter_get(tag))
648648
{
649649
return;
650650
}
@@ -654,6 +654,11 @@ void ulog_hexdump(const char *name, rt_size_t width, rt_uint8_t *buf, rt_size_t
654654
return;
655655
}
656656
#endif /* ULOG_USING_SYSLOG */
657+
else if (!rt_strstr(tag, ulog.filter.tag))
658+
{
659+
/* tag filter */
660+
return;
661+
}
657662
#endif /* ULOG_USING_FILTER */
658663

659664
/* get log buffer */
@@ -668,7 +673,7 @@ void ulog_hexdump(const char *name, rt_size_t width, rt_uint8_t *buf, rt_size_t
668673
if (i == 0)
669674
{
670675
log_len += ulog_strcpy(log_len, log_buf + log_len, "D/HEX ");
671-
log_len += ulog_strcpy(log_len, log_buf + log_len, name);
676+
log_len += ulog_strcpy(log_len, log_buf + log_len, tag);
672677
log_len += ulog_strcpy(log_len, log_buf + log_len, ": ");
673678
}
674679
else

components/utilities/ulog/ulog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void ulog_async_waiting_log(rt_int32_t time);
8383
/*
8484
* dump the hex format data to log
8585
*/
86-
void ulog_hexdump(const char *name, rt_size_t width, rt_uint8_t *buf, rt_size_t size);
86+
void ulog_hexdump(const char *tag, rt_size_t width, rt_uint8_t *buf, rt_size_t size);
8787

8888
/*
8989
* Another log output API. This API is more difficult to use than LOG_X API.

0 commit comments

Comments
 (0)