Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
60ba1e93
R
rt-thread
项目概览
BaiXuePrincess
/
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看板
未验证
提交
60ba1e93
编写于
11月 01, 2018
作者:
B
Bernard Xiong
提交者:
GitHub
11月 01, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1942 from armink/add_ulog
[component][ulog] Reduce thread stack usage when using ulog.
上级
5aeb8dce
c336099a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
45 addition
and
9 deletion
+45
-9
components/utilities/Kconfig
components/utilities/Kconfig
+1
-1
components/utilities/ulog/ulog.c
components/utilities/ulog/ulog.c
+40
-5
components/utilities/ulog/ulog.h
components/utilities/ulog/ulog.h
+1
-1
components/utilities/ulog/ulog_def.h
components/utilities/ulog/ulog_def.h
+3
-2
未找到文件。
components/utilities/Kconfig
浏览文件 @
60ba1e93
...
...
@@ -162,7 +162,7 @@ config RT_USING_ULOG
menu "log format"
config ULOG_OUTPUT_FLOAT
bool "Enable float number support."
bool "Enable float number support.
It will using more thread stack.
"
select RT_USING_LIBC
default n
help
...
...
components/utilities/ulog/ulog.c
浏览文件 @
60ba1e93
...
...
@@ -170,6 +170,26 @@ size_t ulog_strcpy(size_t cur_len, char *dst, const char *src)
return
src
-
src_old
;
}
size_t
ulog_ultoa
(
char
*
s
,
unsigned
long
int
n
)
{
size_t
i
=
0
,
j
=
0
,
len
=
0
;
char
swap
;
do
{
s
[
len
++
]
=
n
%
10
+
'0'
;
}
while
(
n
/=
10
);
s
[
len
]
=
'\0'
;
/* reverse string */
for
(
i
=
0
,
j
=
len
-
1
;
i
<
j
;
++
i
,
--
j
)
{
swap
=
s
[
i
];
s
[
i
]
=
s
[
j
];
s
[
j
]
=
swap
;
}
return
len
;
}
static
void
output_unlock
(
void
)
{
/* is in thread context */
...
...
@@ -221,14 +241,18 @@ static char *get_log_buf(void)
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
)
{
rt_size_t
log_len
=
0
,
newline_len
=
rt_strlen
(
ULOG_NEWLINE_SIGN
);
int
fmt_result
;
/* the caller has locker, so it can use static variable for reduce stack usage */
static
rt_size_t
log_len
,
newline_len
;
static
int
fmt_result
;
RT_ASSERT
(
log_buf
);
RT_ASSERT
(
level
<=
LOG_LVL_DBG
);
RT_ASSERT
(
tag
);
RT_ASSERT
(
format
);
log_len
=
0
;
newline_len
=
rt_strlen
(
ULOG_NEWLINE_SIGN
);
#ifdef ULOG_USING_COLOR
/* add CSI start sign and color info */
if
(
color_output_info
[
level
])
...
...
@@ -242,9 +266,10 @@ RT_WEAK rt_size_t ulog_formater(char *log_buf, rt_uint32_t level, const char *ta
/* add time info */
{
#ifdef ULOG_TIME_USING_TIMESTAMP
time_t
now
=
time
(
NULL
)
;
struct
tm
*
tm
,
tm_tmp
;
static
time_t
now
;
st
atic
st
ruct
tm
*
tm
,
tm_tmp
;
now
=
time
(
NULL
);
tm
=
gmtime_r
(
&
now
,
&
tm_tmp
);
#ifdef RT_USING_SOFT_RTC
...
...
@@ -256,7 +281,12 @@ RT_WEAK rt_size_t ulog_formater(char *log_buf, rt_uint32_t level, const char *ta
#endif
/* RT_USING_SOFT_RTC */
#else
rt_snprintf
(
log_buf
+
log_len
,
ULOG_LINE_BUF_SIZE
-
log_len
,
"[%d]"
,
rt_tick_get
());
static
rt_size_t
tick_len
=
0
;
log_buf
[
log_len
]
=
'['
;
tick_len
=
ulog_ultoa
(
log_buf
+
log_len
+
1
,
rt_tick_get
());
log_buf
[
log_len
+
1
+
tick_len
]
=
']'
;
log_buf
[
log_len
+
1
+
tick_len
+
1
]
=
'\0'
;
#endif
/* ULOG_TIME_USING_TIMESTAMP */
log_len
+=
rt_strlen
(
log_buf
+
log_len
);
...
...
@@ -988,6 +1018,11 @@ rt_err_t ulog_backend_unregister(ulog_backend_t backend)
RT_ASSERT
(
backend
);
RT_ASSERT
(
ulog
.
init_ok
);
if
(
backend
->
deinit
)
{
backend
->
deinit
(
backend
);
}
level
=
rt_hw_interrupt_disable
();
rt_slist_remove
(
&
ulog
.
backend_list
,
&
backend
->
list
);
rt_hw_interrupt_enable
(
level
);
...
...
components/utilities/ulog/ulog.h
浏览文件 @
60ba1e93
...
...
@@ -82,7 +82,7 @@ void ulog_async_waiting_log(rt_int32_t time);
void
ulog_hexdump
(
const
char
*
name
,
rt_size_t
width
,
rt_uint8_t
*
buf
,
rt_size_t
size
);
/*
* Another log output API. This API is difficult to use than LOG_X API.
* Another log output API. This API is
more
difficult to use than LOG_X API.
*/
void
ulog_voutput
(
rt_uint32_t
level
,
const
char
*
tag
,
rt_bool_t
newline
,
const
char
*
format
,
va_list
args
);
void
ulog_output
(
rt_uint32_t
level
,
const
char
*
tag
,
rt_bool_t
newline
,
const
char
*
format
,
...);
...
...
components/utilities/ulog/ulog_def.h
浏览文件 @
60ba1e93
...
...
@@ -7,6 +7,7 @@
* Date Author Notes
* 2018-08-25 armink the first version
*/
#ifndef _ULOG_DEF_H_
#define _ULOG_DEF_H_
...
...
@@ -63,9 +64,9 @@ extern "C" {
#if !defined(LOG_LVL)
/* compatible for rtdbg */
#if defined(DBG_LEVEL)
#define LOG_LVL
DBG_LEVEL
#define LOG_LVL DBG_LEVEL
#else
#define LOG_LVL
LOG_LVL_DBG
#define LOG_LVL LOG_LVL_DBG
#endif
#endif
/* !defined(LOG_LVL) */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录