Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
b07bd6c5
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b07bd6c5
编写于
12月 29, 2017
作者:
B
bernard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Utilities] Add more options for logtrace.
上级
09f2d42e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
145 addition
and
11 deletion
+145
-11
components/utilities/Kconfig
components/utilities/Kconfig
+38
-0
components/utilities/logtrace/SConscript
components/utilities/logtrace/SConscript
+9
-1
components/utilities/logtrace/log_trace.c
components/utilities/logtrace/log_trace.c
+23
-8
components/utilities/logtrace/log_trace.h
components/utilities/logtrace/log_trace.h
+14
-2
components/utilities/logtrace/memlog.c
components/utilities/logtrace/memlog.c
+61
-0
未找到文件。
components/utilities/Kconfig
浏览文件 @
b07bd6c5
...
...
@@ -4,6 +4,44 @@ config RT_USING_LOGTRACE
bool "Enable log trace"
default n
if RT_USING_LOGTRACE
config LOG_TRACE_MAX_SESSION
int "Maximal number of session"
default 16
choice
prompt "The default level of log"
default LOG_TRACE_USING_LEVEL_INFO
config LOG_TRACE_USING_LEVEL_NOTRACE
bool "No trace"
config LOG_TRACE_USING_LEVEL_ERROR
bool "Only error log"
config LOG_TRACE_USING_LEVEL_WARNING
bool "Warning log"
config LOG_TRACE_USING_LEVEL_INFO
bool "Information log"
config LOG_TRACE_USING_LEVEL_VERBOSE
bool "Verbose log"
config LOG_TRACE_USING_LEVEL_DEBUG
bool "All debug log"
endchoice
config LOG_TRACE_USING_MEMLOG
bool "Enable memory log for logtrace"
default n
help
Enable memory log for logtrace, then the logs in log_trace
will be printed out in idle thread hook function.
Please make sure the idle hook is not used.
endif
config RT_USING_RYM
bool "Enable Ymodem"
default n
...
...
components/utilities/logtrace/SConscript
浏览文件 @
b07bd6c5
from
building
import
*
cwd
=
GetCurrentDir
()
src
=
Glob
(
'*.c'
)
src
=
Split
(
'''
log_trace.c
'''
)
CPPPATH
=
[
cwd
]
if
GetDepend
(
'LOG_TRACE_USING_MEMLOG'
):
src
+=
[
'memlog.c'
]
if
GetDepend
(
'RT_USING_DFS'
):
src
+=
[
'log_file.c'
]
group
=
DefineGroup
(
'Utilities'
,
src
,
depend
=
[
'RT_USING_LOGTRACE'
],
CPPPATH
=
CPPPATH
)
Return
(
'group'
)
components/utilities/logtrace/log_trace.c
浏览文件 @
b07bd6c5
...
...
@@ -41,7 +41,7 @@ static struct rt_device _log_device;
static
rt_device_t
_traceout_device
=
RT_NULL
;
/* define a default lg session. The name is empty. */
static
struct
log_trace_session
_def_session
=
{{
"
\0
"
},
LOG_TRACE_LEVEL_
INFO
};
static
struct
log_trace_session
_def_session
=
{{
"
\0
"
},
LOG_TRACE_LEVEL_
DEFAULT
};
static
const
struct
log_trace_session
*
_the_sessions
[
LOG_TRACE_MAX_SESSION
]
=
{
&
_def_session
};
/* there is a default session at least */
static
rt_uint16_t
_the_sess_nr
=
1
;
...
...
@@ -267,16 +267,31 @@ void __logtrace_vfmtout(const struct log_trace_session *session,
RT_ASSERT
(
session
);
RT_ASSERT
(
fmt
);
rt_snprintf
(
_trace_buf
,
sizeof
(
_trace_buf
),
"[%08x]["
,
rt_tick_get
());
if
(
_traceout_device
!=
RT_NULL
)
/* it's default session */
if
(
session
->
id
.
name
[
0
]
==
'\0'
)
{
rt_device_write
(
_traceout_device
,
-
1
,
_trace_buf
,
11
);
rt_device_write
(
_traceout_device
,
-
1
,
session
->
id
.
name
,
_idname_len
(
session
->
id
.
num
));
rt_snprintf
(
_trace_buf
,
sizeof
(
_trace_buf
),
"[%08x]"
,
rt_tick_get
());
if
(
_traceout_device
!=
RT_NULL
)
{
rt_device_write
(
_traceout_device
,
-
1
,
_trace_buf
,
10
);
}
ptr
=
&
_trace_buf
[
0
];
}
else
{
rt_snprintf
(
_trace_buf
,
sizeof
(
_trace_buf
),
"[%08x]["
,
rt_tick_get
());
if
(
_traceout_device
!=
RT_NULL
)
{
rt_device_write
(
_traceout_device
,
-
1
,
_trace_buf
,
11
);
rt_device_write
(
_traceout_device
,
-
1
,
session
->
id
.
name
,
_idname_len
(
session
->
id
.
num
));
}
_trace_buf
[
0
]
=
']'
;
ptr
=
&
_trace_buf
[
1
];
}
_trace_buf
[
0
]
=
']'
;
ptr
=
&
_trace_buf
[
1
];
length
=
rt_vsnprintf
(
ptr
,
LOG_TRACE_BUFSZ
,
fmt
,
argptr
);
if
(
length
>=
LOG_TRACE_BUFSZ
)
...
...
components/utilities/logtrace/log_trace.h
浏览文件 @
b07bd6c5
...
...
@@ -37,8 +37,20 @@
#define LOG_TRACE_LEVEL_DEBUG 0x09
#define LOG_TRACE_LEVEL_ALL 0x0f
#ifndef LOG_TRACE_LEVEL_DEFAULT
#define LOG_TRACE_LEVEL_DEFAULT LOG_TRACE_LEVEL_INFO
#if defined(LOG_TRACE_USING_LEVEL_NOTRACE)
#define LOG_TRACE_LEVEL_DEFAULT LOG_TRACE_LEVEL_NOTRACE
#elif defined(LOG_TRACE_USING_LEVEL_ERROR)
#define LOG_TRACE_LEVEL_DEFAULT LOG_TRACE_LEVEL_ERROR
#elif defined(LOG_TRACE_USING_LEVEL_WARNING)
#define LOG_TRACE_LEVEL_DEFAULT LOG_TRACE_LEVEL_WARNING
#elif defined(LOG_TRACE_USING_LEVEL_INFO)
#define LOG_TRACE_LEVEL_DEFAULT LOG_TRACE_LEVEL_INFO
#elif defined(LOG_TRACE_USING_LEVEL_VERBOSE)
#define LOG_TRACE_LEVEL_DEFAULT LOG_TRACE_LEVEL_VERBOSE
#elif defined(LOG_TRACE_USING_LEVEL_DEBUG)
#define LOG_TRACE_LEVEL_DEFAULT LOG_TRACE_LEVEL_DEBUG
#else
#define LOG_TRACE_LEVEL_DEFAULT LOG_TRACE_LEVEL_INFO
#endif
#define LOG_TRACE_ERROR "<1>"
...
...
components/utilities/logtrace/memlog.c
0 → 100644
浏览文件 @
b07bd6c5
/*
* File : memlog.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2013, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2013-06-26 Grissiom the first version
*/
#include <rtthread.h>
#include <rtdevice.h>
#include <log_trace.h>
#define PIPE_SZ 2048
#define PIPE_NAME "memlog"
static
rt_pipe_t
*
_log_pipe
=
NULL
;
static
rt_uint8_t
outbuf
[
1024
];
void
memlog_flush
(
void
)
{
rt_size_t
readsz
;
rt_device_t
console
;
console
=
rt_console_get_device
();
if
(
!
console
)
return
;
readsz
=
rt_device_read
((
rt_device_t
)
&
(
_log_pipe
->
parent
),
0
,
outbuf
,
sizeof
(
outbuf
));
if
(
readsz
)
rt_device_write
(
console
,
0
,
outbuf
,
readsz
);
}
int
memlog_init
(
void
)
{
_log_pipe
=
rt_pipe_create
(
PIPE_NAME
,
PIPE_SZ
);
if
(
_log_pipe
==
RT_NULL
)
{
rt_kprintf
(
"init pipe device failed.
\n
"
);
return
-
1
;
}
log_trace_set_device
(
PIPE_NAME
);
rt_thread_idle_sethook
(
memlog_flush
);
return
0
;
}
INIT_APP_EXPORT
(
memlog_init
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录