Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
AdRainty
rt-thread
提交
d8d15017
R
rt-thread
项目概览
AdRainty
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d8d15017
编写于
12月 03, 2021
作者:
armink_ztl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[ulog] Add ulog backend filter.
上级
bb8f2691
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
48 addition
and
2 deletion
+48
-2
components/utilities/ulog/backend/console_be.c
components/utilities/ulog/backend/console_be.c
+1
-1
components/utilities/ulog/ulog.c
components/utilities/ulog/ulog.c
+42
-1
components/utilities/ulog/ulog.h
components/utilities/ulog/ulog.h
+2
-0
components/utilities/ulog/ulog_def.h
components/utilities/ulog/ulog_def.h
+3
-0
未找到文件。
components/utilities/ulog/backend/console_be.c
浏览文件 @
d8d15017
...
...
@@ -17,7 +17,7 @@
#error "The thread stack size must more than 384 when using async output by thread (ULOG_ASYNC_OUTPUT_BY_THREAD)"
#endif
static
struct
ulog_backend
console
;
static
struct
ulog_backend
console
=
{
0
}
;
void
ulog_console_backend_output
(
struct
ulog_backend
*
backend
,
rt_uint32_t
level
,
const
char
*
tag
,
rt_bool_t
is_raw
,
const
char
*
log
,
size_t
len
)
...
...
components/utilities/ulog/ulog.c
浏览文件 @
d8d15017
...
...
@@ -244,6 +244,7 @@ static char *get_log_buf(void)
}
}
extern
struct
tm
*
localtime_r
(
const
time_t
*
t
,
struct
tm
*
r
);
RT_WEAK
rt_size_t
ulog_formater
(
char
*
log_buf
,
rt_uint32_t
level
,
const
char
*
tag
,
rt_bool_t
newline
,
const
char
*
format
,
va_list
args
)
{
...
...
@@ -439,6 +440,11 @@ void ulog_output_to_all_backend(rt_uint32_t level, const char *tag, rt_bool_t is
#if !defined(ULOG_USING_COLOR) || defined(ULOG_USING_SYSLOG)
backend
->
output
(
backend
,
level
,
tag
,
is_raw
,
log
,
size
);
#else
if
(
backend
->
filter
&&
backend
->
filter
(
backend
,
level
,
tag
,
is_raw
,
log
,
size
)
==
RT_FALSE
)
{
/* backend's filter is not match, so skip output */
continue
;
}
if
(
backend
->
support_color
||
is_raw
)
{
backend
->
output
(
backend
,
level
,
tag
,
is_raw
,
log
,
size
);
...
...
@@ -447,7 +453,7 @@ void ulog_output_to_all_backend(rt_uint32_t level, const char *tag, rt_bool_t is
{
/* recalculate the log start address and log size when backend not supported color */
rt_size_t
color_info_len
=
0
,
output_size
=
size
;
char
*
output_log
=
log
;
c
onst
c
har
*
output_log
=
log
;
if
(
color_output_info
[
level
]
!=
RT_NULL
)
color_info_len
=
rt_strlen
(
color_output_info
[
level
]);
...
...
@@ -1300,6 +1306,41 @@ rt_err_t ulog_backend_unregister(ulog_backend_t backend)
return
RT_EOK
;
}
rt_err_t
ulog_backend_set_filter
(
ulog_backend_t
backend
,
ulog_backend_filter_t
filter
)
{
rt_base_t
level
;
RT_ASSERT
(
backend
);
level
=
rt_hw_interrupt_disable
();
backend
->
filter
=
filter
;
rt_hw_interrupt_enable
(
level
);
return
RT_EOK
;
}
ulog_backend_t
ulog_backend_find
(
const
char
*
name
)
{
rt_base_t
level
;
rt_slist_t
*
node
;
ulog_backend_t
backend
;
RT_ASSERT
(
ulog
.
init_ok
);
level
=
rt_hw_interrupt_disable
();
for
(
node
=
rt_slist_first
(
&
ulog
.
backend_list
);
node
;
node
=
rt_slist_next
(
node
))
{
backend
=
rt_slist_entry
(
node
,
struct
ulog_backend
,
list
);
if
(
rt_strncmp
(
backend
->
name
,
name
,
RT_NAME_MAX
)
==
0
)
{
rt_hw_interrupt_enable
(
level
);
return
backend
;
}
}
rt_hw_interrupt_enable
(
level
);
return
RT_NULL
;
}
#ifdef ULOG_USING_ASYNC_OUTPUT
/**
* asynchronous output logs to all backends
...
...
components/utilities/ulog/ulog.h
浏览文件 @
d8d15017
...
...
@@ -54,6 +54,8 @@ void ulog_deinit(void);
*/
rt_err_t
ulog_backend_register
(
ulog_backend_t
backend
,
const
char
*
name
,
rt_bool_t
support_color
);
rt_err_t
ulog_backend_unregister
(
ulog_backend_t
backend
);
rt_err_t
ulog_backend_set_filter
(
ulog_backend_t
backend
,
ulog_backend_filter_t
filter
);
ulog_backend_t
ulog_backend_find
(
const
char
*
name
);
#ifdef ULOG_USING_FILTER
/*
...
...
components/utilities/ulog/ulog_def.h
浏览文件 @
d8d15017
...
...
@@ -211,9 +211,12 @@ struct ulog_backend
void
(
*
output
)(
struct
ulog_backend
*
backend
,
rt_uint32_t
level
,
const
char
*
tag
,
rt_bool_t
is_raw
,
const
char
*
log
,
size_t
len
);
void
(
*
flush
)
(
struct
ulog_backend
*
backend
);
void
(
*
deinit
)(
struct
ulog_backend
*
backend
);
/* The filter will be call before output. It will return TRUE when the filter condition is math. */
rt_bool_t
(
*
filter
)(
struct
ulog_backend
*
backend
,
rt_uint32_t
level
,
const
char
*
tag
,
rt_bool_t
is_raw
,
const
char
*
log
,
size_t
len
);
rt_slist_t
list
;
};
typedef
struct
ulog_backend
*
ulog_backend_t
;
typedef
rt_bool_t
(
*
ulog_backend_filter_t
)(
struct
ulog_backend
*
backend
,
rt_uint32_t
level
,
const
char
*
tag
,
rt_bool_t
is_raw
,
const
char
*
log
,
size_t
len
);
#ifdef __cplusplus
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录