Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ea43a849
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看板
提交
ea43a849
编写于
2月 27, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ulog
上级
6c60dc8e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
51 addition
and
84 deletion
+51
-84
include/util/tlog.h
include/util/tlog.h
+12
-0
include/util/ulog.h
include/util/ulog.h
+0
-43
source/util/src/tlog.c
source/util/src/tlog.c
+39
-41
未找到文件。
include/util/tlog.h
浏览文件 @
ea43a849
...
@@ -68,6 +68,18 @@ void taosPrintLongString(const char *flags, int32_t dflag, const char *format, .
...
@@ -68,6 +68,18 @@ void taosPrintLongString(const char *flags, int32_t dflag, const char *format, .
#endif
#endif
;
;
extern
int8_t
tscEmbeddedInUtil
;
#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", tscEmbeddedInUtil ? 255 : uDebugFlag, __VA_ARGS__); }}
#define uError(...) { if (uDebugFlag & DEBUG_ERROR) { taosPrintLog("UTL ERROR ", tscEmbeddedInUtil ? 255 : uDebugFlag, __VA_ARGS__); }}
#define uWarn(...) { if (uDebugFlag & DEBUG_WARN) { taosPrintLog("UTL WARN ", tscEmbeddedInUtil ? 255 : uDebugFlag, __VA_ARGS__); }}
#define uInfo(...) { if (uDebugFlag & DEBUG_INFO) { taosPrintLog("UTL ", tscEmbeddedInUtil ? 255 : uDebugFlag, __VA_ARGS__); }}
#define uDebug(...) { if (uDebugFlag & DEBUG_DEBUG) { taosPrintLog("UTL ", uDebugFlag, __VA_ARGS__); }}
#define uTrace(...) { if (uDebugFlag & DEBUG_TRACE) { taosPrintLog("UTL ", uDebugFlag, __VA_ARGS__); }}
#define pError(...) { taosPrintLog("APP ERROR ", 255, __VA_ARGS__); }
#define pPrint(...) { taosPrintLog("APP ", 255, __VA_ARGS__); }
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/util/ulog.h
已删除
100644 → 0
浏览文件 @
6c60dc8e
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* 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.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_UTIL_ULOG_H
#define _TD_UTIL_ULOG_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include "os.h"
#include "tlog.h"
extern
int32_t
uDebugFlag
;
extern
int8_t
tscEmbeddedInUtil
;
#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", tscEmbeddedInUtil ? 255 : uDebugFlag, __VA_ARGS__); }}
#define uError(...) { if (uDebugFlag & DEBUG_ERROR) { taosPrintLog("UTL ERROR ", tscEmbeddedInUtil ? 255 : uDebugFlag, __VA_ARGS__); }}
#define uWarn(...) { if (uDebugFlag & DEBUG_WARN) { taosPrintLog("UTL WARN ", tscEmbeddedInUtil ? 255 : uDebugFlag, __VA_ARGS__); }}
#define uInfo(...) { if (uDebugFlag & DEBUG_INFO) { taosPrintLog("UTL ", tscEmbeddedInUtil ? 255 : uDebugFlag, __VA_ARGS__); }}
#define uDebug(...) { if (uDebugFlag & DEBUG_DEBUG) { taosPrintLog("UTL ", uDebugFlag, __VA_ARGS__); }}
#define uTrace(...) { if (uDebugFlag & DEBUG_TRACE) { taosPrintLog("UTL ", uDebugFlag, __VA_ARGS__); }}
#define pError(...) { taosPrintLog("APP ERROR ", 255, __VA_ARGS__); }
#define pPrint(...) { taosPrintLog("APP ", 255, __VA_ARGS__); }
#ifdef __cplusplus
}
#endif
#endif
/*_TD_UTIL_ULOG_H*/
source/util/src/tlog.c
浏览文件 @
ea43a849
...
@@ -14,32 +14,30 @@
...
@@ -14,32 +14,30 @@
*/
*/
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "tlog.h"
#include "os.h"
#include "tutil.h"
#include "tutil.h"
#include "ulog.h"
#include "ulog.h"
#define LOG_MAX_LINE_SIZE (1000)
#define LOG_MAX_LINE_SIZE
(1000)
#define LOG_MAX_LINE_BUFFER_SIZE (LOG_MAX_LINE_SIZE + 10)
#define LOG_MAX_LINE_BUFFER_SIZE
(LOG_MAX_LINE_SIZE + 10)
#define LOG_MAX_LINE_CONTENT_SIZE (LOG_MAX_LINE_SIZE - 100)
#define LOG_MAX_LINE_CONTENT_SIZE
(LOG_MAX_LINE_SIZE - 100)
#define LOG_MAX_LINE_DUMP_SIZE (65 * 1024)
#define LOG_MAX_LINE_DUMP_SIZE
(65 * 1024)
#define LOG_MAX_LINE_DUMP_BUFFER_SIZE (LOG_MAX_LINE_DUMP_SIZE + 10)
#define LOG_MAX_LINE_DUMP_BUFFER_SIZE
(LOG_MAX_LINE_DUMP_SIZE + 10)
#define LOG_MAX_LINE_DUMP_CONTENT_SIZE (LOG_MAX_LINE_DUMP_SIZE - 100)
#define LOG_MAX_LINE_DUMP_CONTENT_SIZE (LOG_MAX_LINE_DUMP_SIZE - 100)
#define LOG_FILE_NAME_LEN 300
#define LOG_FILE_NAME_LEN
300
#define
TSDB_DEFAULT_LOG
_BUF_SIZE (20 * 1024 * 1024) // 20MB
#define
LOG_DEFAULT
_BUF_SIZE (20 * 1024 * 1024) // 20MB
#define
DEFAULT_LOG
_INTERVAL 25
#define
LOG_DEFAULT
_INTERVAL 25
#define LOG_INTERVAL_STEP 5
#define LOG_INTERVAL_STEP
5
#define
MIN_LOG_INTERVAL
5
#define
LOG_MIN_INTERVAL
5
#define
MAX_LOG_INTERVAL
25
#define
LOG_MAX_INTERVAL
25
#define LOG_MAX_WAIT_MSEC 1000
#define LOG_MAX_WAIT_MSEC
1000
#define LOG_BUF_BUFFER(x) ((x)->buffer)
#define LOG_BUF_BUFFER(x) ((x)->buffer)
#define LOG_BUF_START(x) ((x)->buffStart)
#define LOG_BUF_START(x)
((x)->buffStart)
#define LOG_BUF_END(x) ((x)->buffEnd)
#define LOG_BUF_END(x)
((x)->buffEnd)
#define LOG_BUF_SIZE(x) ((x)->buffSize)
#define LOG_BUF_SIZE(x)
((x)->buffSize)
#define LOG_BUF_MUTEX(x) ((x)->buffMutex)
#define LOG_BUF_MUTEX(x)
((x)->buffMutex)
typedef
struct
{
typedef
struct
{
char
*
buffer
;
char
*
buffer
;
...
@@ -72,7 +70,7 @@ int32_t tsLogKeepDays = 0;
...
@@ -72,7 +70,7 @@ int32_t tsLogKeepDays = 0;
bool
tsAsyncLog
=
true
;
bool
tsAsyncLog
=
true
;
bool
tsLogInited
=
false
;
bool
tsLogInited
=
false
;
int64_t
asyncLogLostLines
=
0
;
int64_t
asyncLogLostLines
=
0
;
int32_t
writeInterval
=
DEFAULT_LOG
_INTERVAL
;
int32_t
writeInterval
=
LOG_DEFAULT
_INTERVAL
;
// log
// log
int32_t
tsNumOfLogLines
=
10000000
;
int32_t
tsNumOfLogLines
=
10000000
;
...
@@ -123,7 +121,7 @@ int32_t taosInitLog(const char *logName, int maxFiles) {
...
@@ -123,7 +121,7 @@ int32_t taosInitLog(const char *logName, int maxFiles) {
char
fullName
[
PATH_MAX
]
=
{
0
};
char
fullName
[
PATH_MAX
]
=
{
0
};
snprintf
(
fullName
,
PATH_MAX
,
"%s"
TD_DIRSEP
"%s"
,
tsLogDir
,
logName
);
snprintf
(
fullName
,
PATH_MAX
,
"%s"
TD_DIRSEP
"%s"
,
tsLogDir
,
logName
);
tsLogObj
.
logHandle
=
taosLogBuffNew
(
TSDB_DEFAULT_LOG
_BUF_SIZE
);
tsLogObj
.
logHandle
=
taosLogBuffNew
(
LOG_DEFAULT
_BUF_SIZE
);
if
(
tsLogObj
.
logHandle
==
NULL
)
return
-
1
;
if
(
tsLogObj
.
logHandle
==
NULL
)
return
-
1
;
if
(
taosOpenLogFile
(
fullName
,
tsNumOfLogLines
,
maxFiles
)
<
0
)
return
-
1
;
if
(
taosOpenLogFile
(
fullName
,
tsNumOfLogLines
,
maxFiles
)
<
0
)
return
-
1
;
if
(
taosStartLog
()
<
0
)
return
-
1
;
if
(
taosStartLog
()
<
0
)
return
-
1
;
...
@@ -140,7 +138,7 @@ static void taosStopLog() {
...
@@ -140,7 +138,7 @@ static void taosStopLog() {
void
taosCloseLog
()
{
void
taosCloseLog
()
{
taosStopLog
();
taosStopLog
();
// tsem_post(&(tsLogObj.logHandle->buffNotEmpty));
// tsem_post(&(tsLogObj.logHandle->buffNotEmpty));
taosMsleep
(
MAX_LOG
_INTERVAL
/
1000
);
taosMsleep
(
LOG_MAX
_INTERVAL
/
1000
);
if
(
taosCheckPthreadValid
(
tsLogObj
.
logHandle
->
asyncThread
))
{
if
(
taosCheckPthreadValid
(
tsLogObj
.
logHandle
->
asyncThread
))
{
pthread_join
(
tsLogObj
.
logHandle
->
asyncThread
,
NULL
);
pthread_join
(
tsLogObj
.
logHandle
->
asyncThread
,
NULL
);
}
}
...
@@ -629,7 +627,7 @@ static void taosWriteLog(SLogBuff *tLogBuff) {
...
@@ -629,7 +627,7 @@ static void taosWriteLog(SLogBuff *tLogBuff) {
if
(
start
==
end
)
{
if
(
start
==
end
)
{
dbgEmptyW
++
;
dbgEmptyW
++
;
writeInterval
=
MAX_LOG
_INTERVAL
;
writeInterval
=
LOG_MAX
_INTERVAL
;
return
;
return
;
}
}
...
@@ -658,14 +656,14 @@ static void taosWriteLog(SLogBuff *tLogBuff) {
...
@@ -658,14 +656,14 @@ static void taosWriteLog(SLogBuff *tLogBuff) {
if
(
pollSize
<
tLogBuff
->
minBuffSize
)
{
if
(
pollSize
<
tLogBuff
->
minBuffSize
)
{
dbgSmallWN
++
;
dbgSmallWN
++
;
if
(
writeInterval
<
MAX_LOG
_INTERVAL
)
{
if
(
writeInterval
<
LOG_MAX
_INTERVAL
)
{
writeInterval
+=
LOG_INTERVAL_STEP
;
writeInterval
+=
LOG_INTERVAL_STEP
;
}
}
}
else
if
(
pollSize
>
LOG_BUF_SIZE
(
tLogBuff
)
/
3
)
{
}
else
if
(
pollSize
>
LOG_BUF_SIZE
(
tLogBuff
)
/
3
)
{
dbgBigWN
++
;
dbgBigWN
++
;
writeInterval
=
MIN_LOG
_INTERVAL
;
writeInterval
=
LOG_MIN
_INTERVAL
;
}
else
if
(
pollSize
>
LOG_BUF_SIZE
(
tLogBuff
)
/
4
)
{
}
else
if
(
pollSize
>
LOG_BUF_SIZE
(
tLogBuff
)
/
4
)
{
if
(
writeInterval
>
MIN_LOG
_INTERVAL
)
{
if
(
writeInterval
>
LOG_MIN
_INTERVAL
)
{
writeInterval
-=
LOG_INTERVAL_STEP
;
writeInterval
-=
LOG_INTERVAL_STEP
;
}
}
}
}
...
@@ -680,7 +678,7 @@ static void taosWriteLog(SLogBuff *tLogBuff) {
...
@@ -680,7 +678,7 @@ static void taosWriteLog(SLogBuff *tLogBuff) {
break
;
break
;
}
}
writeInterval
=
MIN_LOG
_INTERVAL
;
writeInterval
=
LOG_MIN
_INTERVAL
;
remainChecked
=
1
;
remainChecked
=
1
;
}
while
(
1
);
}
while
(
1
);
...
@@ -707,7 +705,7 @@ int32_t taosCompressFile(char *srcFileName, char *destFileName) {
...
@@ -707,7 +705,7 @@ int32_t taosCompressFile(char *srcFileName, char *destFileName) {
int32_t
ret
=
0
;
int32_t
ret
=
0
;
int32_t
len
=
0
;
int32_t
len
=
0
;
char
*
data
=
malloc
(
compressSize
);
char
*
data
=
malloc
(
compressSize
);
// gzFile dstFp = NULL;
// gzFile dstFp = NULL;
// srcFp = fopen(srcFileName, "r");
// srcFp = fopen(srcFileName, "r");
TdFilePtr
pSrcFile
=
taosOpenFile
(
srcFileName
,
TD_FILE_READ
);
TdFilePtr
pSrcFile
=
taosOpenFile
(
srcFileName
,
TD_FILE_READ
);
...
@@ -722,25 +720,25 @@ int32_t taosCompressFile(char *srcFileName, char *destFileName) {
...
@@ -722,25 +720,25 @@ int32_t taosCompressFile(char *srcFileName, char *destFileName) {
goto
cmp_end
;
goto
cmp_end
;
}
}
// dstFp = gzdopen(fd, "wb6f");
// dstFp = gzdopen(fd, "wb6f");
// if (dstFp == NULL) {
// if (dstFp == NULL) {
// ret = -3;
// ret = -3;
// close(fd);
// close(fd);
// goto cmp_end;
// goto cmp_end;
// }
// }
//
//
// while (!feof(srcFp)) {
// while (!feof(srcFp)) {
// len = (int32_t)fread(data, 1, compressSize, srcFp);
// len = (int32_t)fread(data, 1, compressSize, srcFp);
// (void)gzwrite(dstFp, data, len);
// (void)gzwrite(dstFp, data, len);
// }
// }
cmp_end:
cmp_end:
if
(
pSrcFile
)
{
if
(
pSrcFile
)
{
taosCloseFile
(
&
pSrcFile
);
taosCloseFile
(
&
pSrcFile
);
}
}
// if (dstFp) {
// if (dstFp) {
// gzclose(dstFp);
// gzclose(dstFp);
// }
// }
free
(
data
);
free
(
data
);
return
ret
;
return
ret
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录