Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
dd423067
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
dd423067
编写于
1月 15, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add debug log
上级
695572cc
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
70 addition
and
3 deletion
+70
-3
src/client/inc/tscLog.h
src/client/inc/tscLog.h
+3
-3
src/util/inc/tlog.h
src/util/inc/tlog.h
+7
-0
src/util/src/tlog.c
src/util/src/tlog.c
+60
-0
未找到文件。
src/client/inc/tscLog.h
浏览文件 @
dd423067
...
...
@@ -28,9 +28,9 @@ extern int8_t tscEmbedded;
#define tscFatal(...) do { if (cDebugFlag & DEBUG_FATAL) { taosPrintLog("TSC FATAL ", tscEmbedded ? 255 : cDebugFlag, __VA_ARGS__); }} while(0)
#define tscError(...) do { if (cDebugFlag & DEBUG_ERROR) { taosPrintLog("TSC ERROR ", tscEmbedded ? 255 : cDebugFlag, __VA_ARGS__); }} while(0)
#define tscWarn(...) do { if (cDebugFlag & DEBUG_WARN) { taosPrintLog("TSC WARN ", tscEmbedded ? 255 : cDebugFlag, __VA_ARGS__); }} while(0)
#define tscInfo(...) do { if (cDebugFlag & DEBUG_INFO) { taos
PrintLog("TSC ", tscEmbedded ? 255 : cDebugFlag,
__VA_ARGS__); }} while(0)
#define tscDebug(...) do { if (cDebugFlag & DEBUG_DEBUG) { taos
PrintLog("TSC ", cDebugFlag
, __VA_ARGS__); }} while(0)
#define tscTrace(...) do { if (cDebugFlag & DEBUG_TRACE) { taos
PrintLog("TSC ", cDebugFlag,
__VA_ARGS__); }} while(0)
#define tscInfo(...) do { if (cDebugFlag & DEBUG_INFO) { taos
DbgPrintLog("TSC ", tscEmbedded ? 255 : cDebugFlag, __FILE__, __LINE__,
__VA_ARGS__); }} while(0)
#define tscDebug(...) do { if (cDebugFlag & DEBUG_DEBUG) { taos
DbgPrintLog("TSC ", cDebugFlag, __FILE__, __LINE__
, __VA_ARGS__); }} while(0)
#define tscTrace(...) do { if (cDebugFlag & DEBUG_TRACE) { taos
DbgPrintLog("TSC ", cDebugFlag, __FILE__, __LINE__,
__VA_ARGS__); }} while(0)
#define tscDebugL(...) do { if (cDebugFlag & DEBUG_DEBUG) { taosPrintLongString("TSC ", cDebugFlag, __VA_ARGS__); }} while(0)
#ifdef __cplusplus
...
...
src/util/inc/tlog.h
浏览文件 @
dd423067
...
...
@@ -41,6 +41,13 @@ void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...)
#endif
;
void
taosDbgPrintLog
(
const
char
*
flags
,
int32_t
dflag
,
char
*
file
,
int
line
,
const
char
*
format
,
...)
#ifdef __GNUC__
__attribute__
((
format
(
printf
,
5
,
6
)))
#endif
;
void
taosPrintLongString
(
const
char
*
flags
,
int32_t
dflag
,
const
char
*
format
,
...)
#ifdef __GNUC__
__attribute__
((
format
(
printf
,
3
,
4
)))
...
...
src/util/src/tlog.c
浏览文件 @
dd423067
...
...
@@ -345,6 +345,66 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
return
0
;
}
void
taosDbgPrintLog
(
const
char
*
flags
,
int32_t
dflag
,
char
*
file
,
int
line
,
const
char
*
format
,
...)
{
if
(
tsTotalLogDirGB
!=
0
&&
tsAvailLogDirGB
<
tsMinimalLogDirGB
)
{
printf
(
"server disk:%s space remain %.3f GB, total %.1f GB, stop print log.
\n
"
,
tsLogDir
,
tsAvailLogDirGB
,
tsTotalLogDirGB
);
fflush
(
stdout
);
return
;
}
va_list
argpointer
;
char
buffer
[
MAX_LOGLINE_BUFFER_SIZE
]
=
{
0
};
int32_t
len
;
struct
tm
Tm
,
*
ptm
;
struct
timeval
timeSecs
;
time_t
curTime
;
gettimeofday
(
&
timeSecs
,
NULL
);
curTime
=
timeSecs
.
tv_sec
;
ptm
=
localtime_r
(
&
curTime
,
&
Tm
);
len
=
sprintf
(
buffer
,
"%02d/%02d %02d:%02d:%02d.%06d 0x%08"
PRIx64
" %8.8s:%4d "
,
ptm
->
tm_mon
+
1
,
ptm
->
tm_mday
,
ptm
->
tm_hour
,
ptm
->
tm_min
,
ptm
->
tm_sec
,
(
int32_t
)
timeSecs
.
tv_usec
,
taosGetSelfPthreadId
(),
file
,
line
);
len
+=
sprintf
(
buffer
+
len
,
"%s"
,
flags
);
va_start
(
argpointer
,
format
);
int32_t
writeLen
=
vsnprintf
(
buffer
+
len
,
MAX_LOGLINE_CONTENT_SIZE
,
format
,
argpointer
);
if
(
writeLen
<=
0
)
{
char
tmp
[
MAX_LOGLINE_DUMP_BUFFER_SIZE
]
=
{
0
};
writeLen
=
vsnprintf
(
tmp
,
MAX_LOGLINE_DUMP_CONTENT_SIZE
,
format
,
argpointer
);
strncpy
(
buffer
+
len
,
tmp
,
MAX_LOGLINE_CONTENT_SIZE
);
len
+=
MAX_LOGLINE_CONTENT_SIZE
;
}
else
if
(
writeLen
>=
MAX_LOGLINE_CONTENT_SIZE
)
{
len
+=
MAX_LOGLINE_CONTENT_SIZE
;
}
else
{
len
+=
writeLen
;
}
va_end
(
argpointer
);
if
(
len
>
MAX_LOGLINE_SIZE
)
len
=
MAX_LOGLINE_SIZE
;
buffer
[
len
++
]
=
'\n'
;
buffer
[
len
]
=
0
;
if
((
dflag
&
DEBUG_FILE
)
&&
tsLogObj
.
logHandle
&&
tsLogObj
.
logHandle
->
fd
>=
0
)
{
if
(
tsAsyncLog
)
{
taosPushLogBuffer
(
tsLogObj
.
logHandle
,
buffer
,
len
);
}
else
{
taosWrite
(
tsLogObj
.
logHandle
->
fd
,
buffer
,
len
);
}
if
(
tsLogObj
.
maxLines
>
0
)
{
atomic_add_fetch_32
(
&
tsLogObj
.
lines
,
1
);
if
((
tsLogObj
.
lines
>
tsLogObj
.
maxLines
)
&&
(
tsLogObj
.
openInProgress
==
0
))
taosOpenNewLogFile
();
}
}
if
(
dflag
&
DEBUG_SCREEN
)
taosWrite
(
1
,
buffer
,
(
uint32_t
)
len
);
if
(
dflag
==
255
)
nInfo
(
buffer
,
len
);
}
void
taosPrintLog
(
const
char
*
flags
,
int32_t
dflag
,
const
char
*
format
,
...)
{
if
(
tsTotalLogDirGB
!=
0
&&
tsAvailLogDirGB
<
tsMinimalLogDirGB
)
{
printf
(
"server disk:%s space remain %.3f GB, total %.1f GB, stop print log.
\n
"
,
tsLogDir
,
tsAvailLogDirGB
,
tsTotalLogDirGB
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录