Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d4a280d8
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d4a280d8
编写于
3月 04, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
log level
上级
7b054eac
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
9 deletion
+31
-9
include/libs/monitor/monitor.h
include/libs/monitor/monitor.h
+10
-3
source/libs/monitor/src/monitor.c
source/libs/monitor/src/monitor.c
+16
-1
source/libs/monitor/test/monTest.cpp
source/libs/monitor/test/monTest.cpp
+5
-5
未找到文件。
include/libs/monitor/monitor.h
浏览文件 @
d4a280d8
...
...
@@ -126,10 +126,17 @@ typedef struct {
SMonDiskDesc
tempdir
;
}
SMonDiskInfo
;
typedef
enum
{
MON_LEVEL_ERROR
=
0
,
MON_LEVEL_INFO
=
1
,
MON_LEVEL_DEBUG
=
2
,
MON_LEVEL_TRACE
=
3
,
}
EMonLogLevel
;
typedef
struct
{
int64_t
ts
;
int8_t
level
;
char
content
[
MON_LOG_LEN
];
int64_t
ts
;
EMonLogLevel
level
;
char
content
[
MON_LOG_LEN
];
}
SMonLogItem
;
typedef
struct
SMonInfo
SMonInfo
;
...
...
source/libs/monitor/src/monitor.c
浏览文件 @
d4a280d8
...
...
@@ -270,6 +270,21 @@ void monSetDiskInfo(SMonInfo *pMonitor, SMonDiskInfo *pInfo) {
tjsonAddDoubleToObject
(
pTempdirJson
,
"total"
,
pInfo
->
tempdir
.
size
.
total
);
}
static
const
char
*
monLogLevelStr
(
EMonLogLevel
level
)
{
switch
(
level
)
{
case
MON_LEVEL_ERROR
:
return
"error"
;
case
MON_LEVEL_INFO
:
return
"info"
;
case
MON_LEVEL_DEBUG
:
return
"debug"
;
case
MON_LEVEL_TRACE
:
return
"trace"
;
default:
return
"undefine"
;
}
}
static
void
monSetLogInfo
(
SMonInfo
*
pMonitor
)
{
SJson
*
pJson
=
tjsonCreateObject
();
if
(
pJson
==
NULL
)
return
;
...
...
@@ -291,7 +306,7 @@ static void monSetLogInfo(SMonInfo *pMonitor) {
taosFormatUtcTime
(
buf
,
sizeof
(
buf
),
pLogItem
->
ts
,
TSDB_TIME_PRECISION_MILLI
);
tjsonAddStringToObject
(
pLogJson
,
"ts"
,
buf
);
tjsonAdd
DoubleToObject
(
pLogJson
,
"level"
,
pLogItem
->
level
);
tjsonAdd
StringToObject
(
pLogJson
,
"level"
,
monLogLevelStr
(
pLogItem
->
level
)
);
tjsonAddStringToObject
(
pLogJson
,
"content"
,
pLogItem
->
content
);
if
(
tjsonAddItemToArray
(
pLogsJson
,
pLogJson
)
!=
0
)
tjsonDelete
(
pLogJson
);
...
...
source/libs/monitor/test/monTest.cpp
浏览文件 @
d4a280d8
...
...
@@ -195,19 +195,19 @@ void MonitorTest::GetDiskInfo(SMonInfo *pMonitor, SMonDiskInfo *pInfo) {
void
MonitorTest
::
AddLogInfo1
()
{
SMonLogItem
log1
=
{
0
};
log1
.
ts
=
taosGetTimestampMs
();
log1
.
level
=
1
;
log1
.
level
=
MON_LEVEL_INFO
;
strcpy
(
log1
.
content
,
"1 -------------------------- a"
);
monAddLogItem
(
&
log1
);
SMonLogItem
log2
=
{
0
};
log2
.
ts
=
taosGetTimestampMs
();
log2
.
level
=
1
;
log2
.
level
=
MON_LEVEL_ERROR
;
strcpy
(
log2
.
content
,
"1 ------------------------ b"
);
monAddLogItem
(
&
log2
);
SMonLogItem
log3
=
{
0
};
log3
.
ts
=
taosGetTimestampMs
();
log3
.
level
=
1
;
log3
.
level
=
MON_LEVEL_DEBUG
;
strcpy
(
log3
.
content
,
"1 ------- c"
);
monAddLogItem
(
&
log3
);
}
...
...
@@ -215,13 +215,13 @@ void MonitorTest::AddLogInfo1() {
void
MonitorTest
::
AddLogInfo2
()
{
SMonLogItem
log1
;
log1
.
ts
=
taosGetTimestampMs
();
log1
.
level
=
01
;
log1
.
level
=
MON_LEVEL_ERROR
;
strcpy
(
log1
.
content
,
"2 ------- a"
);
monAddLogItem
(
&
log1
);
SMonLogItem
log2
;
log2
.
ts
=
taosGetTimestampMs
();
log2
.
level
=
0
;
log2
.
level
=
MON_LEVEL_ERROR
;
strcpy
(
log2
.
content
,
"2 ------- b"
);
monAddLogItem
(
&
log2
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录