Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
逝缘~
rt-thread
提交
e588dfa6
R
rt-thread
项目概览
逝缘~
/
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,发现更多精彩内容 >>
提交
e588dfa6
编写于
10月 31, 2018
作者:
armink_ztl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[component][ulog] Add newline param for ulog_output API.
上级
12a803bc
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
18 deletion
+33
-18
components/utilities/ulog/syslog/syslog.c
components/utilities/ulog/syslog/syslog.c
+6
-3
components/utilities/ulog/ulog.c
components/utilities/ulog/ulog.c
+14
-8
components/utilities/ulog/ulog.h
components/utilities/ulog/ulog.h
+2
-2
components/utilities/ulog/ulog_def.h
components/utilities/ulog/ulog_def.h
+11
-5
未找到文件。
components/utilities/ulog/syslog/syslog.c
浏览文件 @
e588dfa6
...
...
@@ -95,7 +95,7 @@ void vsyslog(int priority, const char *format, va_list args)
priority
|=
local_facility
;
}
ulog_voutput
(
priority
,
local_ident
,
format
,
args
);
ulog_voutput
(
priority
,
local_ident
,
RT_TRUE
,
format
,
args
);
}
/**
...
...
@@ -169,7 +169,7 @@ static const char *get_month_str(uint8_t month)
}
}
RT_WEAK
rt_size_t
syslog_formater
(
char
*
log_buf
,
int
level
,
const
char
*
tag
,
const
char
*
format
,
va_list
args
)
RT_WEAK
rt_size_t
syslog_formater
(
char
*
log_buf
,
int
level
,
const
char
*
tag
,
rt_bool_t
newline
,
const
char
*
format
,
va_list
args
)
{
extern
size_t
ulog_strcpy
(
size_t
cur_len
,
char
*
dst
,
const
char
*
src
);
...
...
@@ -252,7 +252,10 @@ RT_WEAK rt_size_t syslog_formater(char *log_buf, int level, const char *tag, con
}
/* package newline sign */
log_len
+=
ulog_strcpy
(
log_len
,
log_buf
+
log_len
,
ULOG_NEWLINE_SIGN
);
if
(
newline
)
{
log_len
+=
ulog_strcpy
(
log_len
,
log_buf
+
log_len
,
ULOG_NEWLINE_SIGN
);
}
return
log_len
;
}
...
...
components/utilities/ulog/ulog.c
浏览文件 @
e588dfa6
...
...
@@ -218,7 +218,8 @@ static char *get_log_buf(void)
}
}
RT_WEAK
rt_size_t
ulog_formater
(
char
*
log_buf
,
rt_uint32_t
level
,
const
char
*
tag
,
const
char
*
format
,
va_list
args
)
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
;
...
...
@@ -340,7 +341,10 @@ RT_WEAK rt_size_t ulog_formater(char *log_buf, rt_uint32_t level, const char *ta
}
/* package newline sign */
log_len
+=
ulog_strcpy
(
log_len
,
log_buf
+
log_len
,
ULOG_NEWLINE_SIGN
);
if
(
newline
)
{
log_len
+=
ulog_strcpy
(
log_len
,
log_buf
+
log_len
,
ULOG_NEWLINE_SIGN
);
}
#ifdef ULOG_USING_COLOR
/* add CSI end sign */
...
...
@@ -449,10 +453,11 @@ static void do_output(rt_uint32_t level, const char *tag, rt_bool_t is_raw, cons
*
* @param level level
* @param tag tag
* @param newline has_newline
* @param format output format
* @param args variable argument list
*/
void
ulog_voutput
(
rt_uint32_t
level
,
const
char
*
tag
,
const
char
*
format
,
va_list
args
)
void
ulog_voutput
(
rt_uint32_t
level
,
const
char
*
tag
,
rt_bool_t
newline
,
const
char
*
format
,
va_list
args
)
{
char
*
log_buf
=
NULL
;
rt_size_t
log_len
=
0
;
...
...
@@ -499,10 +504,10 @@ void ulog_voutput(rt_uint32_t level, const char *tag, const char *format, va_lis
output_lock
();
#ifndef ULOG_USING_SYSLOG
log_len
=
ulog_formater
(
log_buf
,
level
,
tag
,
format
,
args
);
log_len
=
ulog_formater
(
log_buf
,
level
,
tag
,
newline
,
format
,
args
);
#else
extern
rt_size_t
syslog_formater
(
char
*
log_buf
,
rt_uint8_t
level
,
const
char
*
tag
,
const
char
*
format
,
va_list
args
);
log_len
=
syslog_formater
(
log_buf
,
level
,
tag
,
format
,
args
);
extern
rt_size_t
syslog_formater
(
char
*
log_buf
,
rt_uint8_t
level
,
const
char
*
tag
,
rt_bool_t
newline
,
const
char
*
format
,
va_list
args
);
log_len
=
syslog_formater
(
log_buf
,
level
,
tag
,
newline
,
format
,
args
);
#endif
/* ULOG_USING_SYSLOG */
#ifdef ULOG_USING_FILTER
...
...
@@ -532,17 +537,18 @@ void ulog_voutput(rt_uint32_t level, const char *tag, const char *format, va_lis
*
* @param level level
* @param tag tag
* @param newline has newline
* @param format output format
* @param ... args
*/
void
ulog_output
(
rt_uint32_t
level
,
const
char
*
tag
,
const
char
*
format
,
...)
void
ulog_output
(
rt_uint32_t
level
,
const
char
*
tag
,
rt_bool_t
newline
,
const
char
*
format
,
...)
{
va_list
args
;
/* args point to the first variable parameter */
va_start
(
args
,
format
);
ulog_voutput
(
level
,
tag
,
format
,
args
);
ulog_voutput
(
level
,
tag
,
newline
,
format
,
args
);
va_end
(
args
);
}
...
...
components/utilities/ulog/ulog.h
浏览文件 @
e588dfa6
...
...
@@ -84,8 +84,8 @@ void ulog_hexdump(const char *name, rt_size_t width, rt_uint8_t *buf, rt_size_t
/*
* Another log output API. This API is difficult to use than LOG_X API.
*/
void
ulog_voutput
(
rt_uint32_t
level
,
const
char
*
tag
,
const
char
*
format
,
va_list
args
);
void
ulog_output
(
rt_uint32_t
level
,
const
char
*
tag
,
const
char
*
format
,
...);
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
,
...);
void
ulog_raw
(
const
char
*
format
,
...);
#ifdef __cplusplus
...
...
components/utilities/ulog/ulog_def.h
浏览文件 @
e588dfa6
...
...
@@ -40,10 +40,16 @@ extern "C" {
#undef DBG_WARNING
#undef DBG_INFO
#undef DBG_LOG
#undef dbg_log
#define DBG_ERROR LOG_LVL_ERROR
#define DBG_WARNING LOG_LVL_WARNING
#define DBG_INFO LOG_LVL_INFO
#define DBG_LOG LOG_LVL_DBG
#define dbg_log(level, ...) \
if ((level) <= DBG_LEVEL) \
{ \
ulog_output(level, LOG_TAG, RT_FALSE, __VA_ARGS__);\
}
#if !defined(LOG_TAG)
/* compatible for rtdbg */
...
...
@@ -64,25 +70,25 @@ extern "C" {
#endif
/* !defined(LOG_LVL) */
#if (LOG_LVL >= LOG_LVL_DBG) && (ULOG_OUTPUT_LVL >= LOG_LVL_DBG)
#define ulog_d(TAG, ...) ulog_output(LOG_LVL_DBG, TAG, __VA_ARGS__)
#define ulog_d(TAG, ...) ulog_output(LOG_LVL_DBG, TAG,
RT_TRUE,
__VA_ARGS__)
#else
#define ulog_d(TAG, ...)
#endif
/* (LOG_LVL >= LOG_LVL_DBG) && (ULOG_OUTPUT_LVL >= LOG_LVL_DBG) */
#if (LOG_LVL >= LOG_LVL_INFO) && (ULOG_OUTPUT_LVL >= LOG_LVL_INFO)
#define ulog_i(TAG, ...) ulog_output(LOG_LVL_INFO, TAG, __VA_ARGS__)
#define ulog_i(TAG, ...) ulog_output(LOG_LVL_INFO, TAG,
RT_TRUE,
__VA_ARGS__)
#else
#define ulog_i(TAG, ...)
#endif
/* (LOG_LVL >= LOG_LVL_INFO) && (ULOG_OUTPUT_LVL >= LOG_LVL_INFO) */
#if (LOG_LVL >= LOG_LVL_WARNING) && (ULOG_OUTPUT_LVL >= LOG_LVL_WARNING)
#define ulog_w(TAG, ...) ulog_output(LOG_LVL_WARNING, TAG, __VA_ARGS__)
#define ulog_w(TAG, ...) ulog_output(LOG_LVL_WARNING, TAG,
RT_TRUE,
__VA_ARGS__)
#else
#define ulog_w(TAG, ...)
#endif
/* (LOG_LVL >= LOG_LVL_WARNING) && (ULOG_OUTPUT_LVL >= LOG_LVL_WARNING) */
#if (LOG_LVL >= LOG_LVL_ERROR) && (ULOG_OUTPUT_LVL >= LOG_LVL_ERROR)
#define ulog_e(TAG, ...) ulog_output(LOG_LVL_ERROR, TAG, __VA_ARGS__)
#define ulog_e(TAG, ...) ulog_output(LOG_LVL_ERROR, TAG,
RT_TRUE,
__VA_ARGS__)
#else
#define ulog_e(TAG, ...)
#endif
/* (LOG_LVL >= LOG_LVL_ERROR) && (ULOG_OUTPUT_LVL >= LOG_LVL_ERROR) */
...
...
@@ -92,7 +98,7 @@ extern "C" {
#define ULOG_ASSERT(EXPR) \
if (!(EXPR)) \
{ \
ulog_output(LOG_LVL_ASSERT, LOG_TAG, "(%s) has assert failed at %s:%ld.", #EXPR, __FUNCTION__, __LINE__); \
ulog_output(LOG_LVL_ASSERT, LOG_TAG,
RT_TRUE,
"(%s) has assert failed at %s:%ld.", #EXPR, __FUNCTION__, __LINE__); \
ulog_flush(); \
while (1); \
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录