Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2301_77017786
rt-thread
提交
ad602f5b
R
rt-thread
项目概览
2301_77017786
/
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,发现更多精彩内容 >>
提交
ad602f5b
编写于
11月 08, 2018
作者:
armink_ztl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[component][ulog] Add filter get API.
上级
2fe79faf
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
62 addition
and
16 deletion
+62
-16
components/utilities/ulog/ulog.c
components/utilities/ulog/ulog.c
+49
-16
components/utilities/ulog/ulog.h
components/utilities/ulog/ulog.h
+4
-0
components/utilities/ulog/ulog_def.h
components/utilities/ulog/ulog_def.h
+9
-0
未找到文件。
components/utilities/ulog/ulog.c
浏览文件 @
ad602f5b
...
...
@@ -74,15 +74,6 @@
#error "the log line buffer size must more than 80"
#endif
/* tag's level filter */
struct
tag_lvl_filter
{
char
tag
[
ULOG_FILTER_TAG_MAX_LEN
+
1
];
rt_uint32_t
level
;
rt_slist_t
list
;
};
typedef
struct
tag_lvl_filter
*
tag_lvl_filter_t
;
struct
rt_ulog
{
rt_bool_t
init_ok
;
...
...
@@ -760,7 +751,7 @@ void ulog_hexdump(const char *name, rt_size_t width, rt_uint8_t *buf, rt_size_t
int
ulog_tag_lvl_filter_set
(
const
char
*
tag
,
rt_uint32_t
level
)
{
rt_slist_t
*
node
;
tag_lvl_filter_t
tag_lvl
=
NULL
;
ulog_
tag_lvl_filter_t
tag_lvl
=
NULL
;
int
result
=
RT_EOK
;
RT_ASSERT
(
level
<=
LOG_FILTER_LVL_ALL
);
...
...
@@ -773,7 +764,7 @@ int ulog_tag_lvl_filter_set(const char *tag, rt_uint32_t level)
/* find the tag in list */
for
(
node
=
rt_slist_first
(
&
ulog
.
filter
.
tag_lvl_list
);
node
;
node
=
rt_slist_next
(
node
))
{
tag_lvl
=
rt_slist_entry
(
node
,
struct
tag_lvl_filter
,
list
);
tag_lvl
=
rt_slist_entry
(
node
,
struct
ulog_
tag_lvl_filter
,
list
);
if
(
!
rt_strncmp
(
tag_lvl
->
tag
,
tag
,
ULOG_FILTER_TAG_MAX_LEN
))
{
break
;
...
...
@@ -804,7 +795,7 @@ int ulog_tag_lvl_filter_set(const char *tag, rt_uint32_t level)
if
(
level
!=
LOG_FILTER_LVL_ALL
)
{
/* new a tag's level filter */
tag_lvl
=
(
tag_lvl_filter_t
)
rt_malloc
(
sizeof
(
struct
tag_lvl_filter
));
tag_lvl
=
(
ulog_tag_lvl_filter_t
)
rt_malloc
(
sizeof
(
struct
ulog_
tag_lvl_filter
));
if
(
tag_lvl
)
{
rt_memset
(
tag_lvl
->
tag
,
0
,
sizeof
(
tag_lvl
->
tag
));
...
...
@@ -835,7 +826,7 @@ int ulog_tag_lvl_filter_set(const char *tag, rt_uint32_t level)
rt_uint32_t
ulog_tag_lvl_filter_get
(
const
char
*
tag
)
{
rt_slist_t
*
node
;
tag_lvl_filter_t
tag_lvl
=
NULL
;
ulog_
tag_lvl_filter_t
tag_lvl
=
NULL
;
rt_uint32_t
level
=
LOG_FILTER_LVL_ALL
;
if
(
!
ulog
.
init_ok
)
...
...
@@ -846,7 +837,7 @@ rt_uint32_t ulog_tag_lvl_filter_get(const char *tag)
/* find the tag in list */
for
(
node
=
rt_slist_first
(
&
ulog
.
filter
.
tag_lvl_list
);
node
;
node
=
rt_slist_next
(
node
))
{
tag_lvl
=
rt_slist_entry
(
node
,
struct
tag_lvl_filter
,
list
);
tag_lvl
=
rt_slist_entry
(
node
,
struct
ulog_
tag_lvl_filter
,
list
);
if
(
!
rt_strncmp
(
tag_lvl
->
tag
,
tag
,
ULOG_FILTER_TAG_MAX_LEN
))
{
level
=
tag_lvl
->
level
;
...
...
@@ -859,6 +850,16 @@ rt_uint32_t ulog_tag_lvl_filter_get(const char *tag)
return
level
;
}
/**
* get the tag's level list on filter
*
* @return tag's level list
*/
rt_slist_t
*
ulog_tag_lvl_list_get
(
void
)
{
return
&
ulog
.
filter
.
tag_lvl_list
;
}
/**
* set log global filter level
*
...
...
@@ -873,6 +874,18 @@ void ulog_global_filter_lvl_set(rt_uint32_t level)
ulog
.
filter
.
level
=
level
;
}
/**
* get log global filter level
*
* @return log level: LOG_LVL_ASSERT, LOG_LVL_ERROR, LOG_LVL_WARNING, LOG_LVL_INFO, LOG_LVL_DBG
* LOG_FILTER_LVL_SILENT: disable all log output, except assert level
* LOG_FILTER_LVL_ALL: enable all log output
*/
rt_uint32_t
ulog_global_filter_lvl_get
(
void
)
{
return
ulog
.
filter
.
level
;
}
/**
* set log global filter tag
*
...
...
@@ -885,6 +898,16 @@ void ulog_global_filter_tag_set(const char *tag)
rt_strncpy
(
ulog
.
filter
.
tag
,
tag
,
ULOG_FILTER_TAG_MAX_LEN
);
}
/**
* get log global filter tag
*
* @return tag
*/
const
char
*
ulog_global_filter_tag_get
(
void
)
{
return
ulog
.
filter
.
tag
;
}
/**
* set log global filter keyword
*
...
...
@@ -897,6 +920,16 @@ void ulog_global_filter_kw_set(const char *keyword)
rt_strncpy
(
ulog
.
filter
.
keyword
,
keyword
,
ULOG_FILTER_KW_MAX_LEN
);
}
/**
* get log global filter keyword
*
* @return keyword
*/
const
char
*
ulog_global_filter_kw_get
(
void
)
{
return
ulog
.
filter
.
keyword
;
}
#if defined(RT_USING_FINSH) && defined(FINSH_USING_MSH)
#include <finsh.h>
...
...
@@ -1198,10 +1231,10 @@ void ulog_deinit(void)
#ifdef ULOG_USING_FILTER
/* deinit tag's level filter */
{
tag_lvl_filter_t
tag_lvl
;
ulog_
tag_lvl_filter_t
tag_lvl
;
for
(
node
=
rt_slist_first
(
&
ulog
.
filter
.
tag_lvl_list
);
node
;
node
=
rt_slist_next
(
node
))
{
tag_lvl
=
rt_slist_entry
(
node
,
struct
tag_lvl_filter
,
list
);
tag_lvl
=
rt_slist_entry
(
node
,
struct
ulog_
tag_lvl_filter
,
list
);
rt_free
(
tag_lvl
);
}
}
...
...
components/utilities/ulog/ulog.h
浏览文件 @
ad602f5b
...
...
@@ -58,9 +58,13 @@ rt_err_t ulog_backend_unregister(ulog_backend_t backend);
*/
int
ulog_tag_lvl_filter_set
(
const
char
*
tag
,
rt_uint32_t
level
);
rt_uint32_t
ulog_tag_lvl_filter_get
(
const
char
*
tag
);
rt_slist_t
*
ulog_tag_lvl_list_get
(
void
);
void
ulog_global_filter_lvl_set
(
rt_uint32_t
level
);
rt_uint32_t
ulog_global_filter_lvl_get
(
void
);
void
ulog_global_filter_tag_set
(
const
char
*
tag
);
const
char
*
ulog_global_filter_tag_get
(
void
);
void
ulog_global_filter_kw_set
(
const
char
*
keyword
);
const
char
*
ulog_global_filter_kw_get
(
void
);
#endif
/* ULOG_USING_FILTER */
/*
...
...
components/utilities/ulog/ulog_def.h
浏览文件 @
ad602f5b
...
...
@@ -165,6 +165,15 @@ extern "C" {
#define ULOG_FRAME_MAGIC 0x10
/* tag's level filter */
struct
ulog_tag_lvl_filter
{
char
tag
[
ULOG_FILTER_TAG_MAX_LEN
+
1
];
rt_uint32_t
level
;
rt_slist_t
list
;
};
typedef
struct
ulog_tag_lvl_filter
*
ulog_tag_lvl_filter_t
;
struct
ulog_frame
{
/* magic word is 0x10 ('lo') */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录