提交 80d0ea13 编写于 作者: S Shengliang Guan

refact log

上级 3548b4d7
...@@ -16,17 +16,18 @@ ...@@ -16,17 +16,18 @@
#ifndef _TD_UTIL_COMPARE_H_ #ifndef _TD_UTIL_COMPARE_H_
#define _TD_UTIL_COMPARE_H_ #define _TD_UTIL_COMPARE_H_
#include "os.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include "os.h"
#define TSDB_PATTERN_MATCH 0 #define TSDB_PATTERN_MATCH 0
#define TSDB_PATTERN_NOMATCH 1 #define TSDB_PATTERN_NOMATCH 1
#define TSDB_PATTERN_NOWILDCARDMATCH 2 #define TSDB_PATTERN_NOWILDCARDMATCH 2
#define TSDB_PATTERN_STRING_DEFAULT_LEN 100 #define TSDB_PATTERN_STRING_DEFAULT_LEN 100
#define TSDB_REGEX_STRING_DEFAULT_LEN 128 #define TSDB_REGEX_STRING_DEFAULT_LEN 128
#define FLT_COMPAR_TOL_FACTOR 4 #define FLT_COMPAR_TOL_FACTOR 4
#define FLT_EQUAL(_x, _y) (fabs((_x) - (_y)) <= (FLT_COMPAR_TOL_FACTOR * FLT_EPSILON)) #define FLT_EQUAL(_x, _y) (fabs((_x) - (_y)) <= (FLT_COMPAR_TOL_FACTOR * FLT_EPSILON))
...@@ -62,7 +63,6 @@ int32_t setChkNotInBytes8(const void *pLeft, const void *pRight); ...@@ -62,7 +63,6 @@ int32_t setChkNotInBytes8(const void *pLeft, const void *pRight);
int32_t compareChkInString(const void *pLeft, const void *pRight); int32_t compareChkInString(const void *pLeft, const void *pRight);
int32_t compareChkNotInString(const void *pLeft, const void *pRight); int32_t compareChkNotInString(const void *pLeft, const void *pRight);
int32_t compareInt8Val(const void *pLeft, const void *pRight); int32_t compareInt8Val(const void *pLeft, const void *pRight);
int32_t compareInt16Val(const void *pLeft, const void *pRight); int32_t compareInt16Val(const void *pLeft, const void *pRight);
int32_t compareInt32Val(const void *pLeft, const void *pRight); int32_t compareInt32Val(const void *pLeft, const void *pRight);
...@@ -83,7 +83,6 @@ int32_t compareStrRegexComp(const void *pLeft, const void *pRight); ...@@ -83,7 +83,6 @@ int32_t compareStrRegexComp(const void *pLeft, const void *pRight);
int32_t compareStrRegexCompMatch(const void *pLeft, const void *pRight); int32_t compareStrRegexCompMatch(const void *pLeft, const void *pRight);
int32_t compareStrRegexCompNMatch(const void *pLeft, const void *pRight); int32_t compareStrRegexCompNMatch(const void *pLeft, const void *pRight);
int32_t compareInt8ValDesc(const void *pLeft, const void *pRight); int32_t compareInt8ValDesc(const void *pLeft, const void *pRight);
int32_t compareInt16ValDesc(const void *pLeft, const void *pRight); int32_t compareInt16ValDesc(const void *pLeft, const void *pRight);
int32_t compareInt32ValDesc(const void *pLeft, const void *pRight); int32_t compareInt32ValDesc(const void *pLeft, const void *pRight);
...@@ -102,7 +101,6 @@ int32_t compareLenPrefixedWStrDesc(const void *pLeft, const void *pRight); ...@@ -102,7 +101,6 @@ int32_t compareLenPrefixedWStrDesc(const void *pLeft, const void *pRight);
__compar_fn_t getComparFunc(int32_t type, int32_t optr); __compar_fn_t getComparFunc(int32_t type, int32_t optr);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
extern "C" { extern "C" {
#endif #endif
extern bool tsLogInited;
extern bool tsAsyncLog; extern bool tsAsyncLog;
extern int32_t tsNumOfLogLines; extern int32_t tsNumOfLogLines;
extern int32_t tsLogKeepDays; extern int32_t tsLogKeepDays;
...@@ -55,7 +54,7 @@ int32_t taosInitLog(const char *logName, int32_t maxFiles); ...@@ -55,7 +54,7 @@ int32_t taosInitLog(const char *logName, int32_t maxFiles);
void taosCloseLog(); void taosCloseLog();
void taosResetLog(); void taosResetLog();
void taosSetAllDebugFlag(int32_t flag); void taosSetAllDebugFlag(int32_t flag);
void taosDumpData(unsigned char *msg, int32_t len); void taosDumpData(uint8_t *msg, int32_t len);
void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...) void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...)
#ifdef __GNUC__ #ifdef __GNUC__
......
...@@ -19,12 +19,12 @@ ...@@ -19,12 +19,12 @@
#include "tutil.h" #include "tutil.h"
#include "ulog.h" #include "ulog.h"
#define MAX_LOGLINE_SIZE (1000) #define LOG_MAX_LINE_SIZE (1000)
#define MAX_LOGLINE_BUFFER_SIZE (MAX_LOGLINE_SIZE + 10) #define LOG_MAX_LINE_BUFFER_SIZE (LOG_MAX_LINE_SIZE + 10)
#define MAX_LOGLINE_CONTENT_SIZE (MAX_LOGLINE_SIZE - 100) #define LOG_MAX_LINE_CONTENT_SIZE (LOG_MAX_LINE_SIZE - 100)
#define MAX_LOGLINE_DUMP_SIZE (65 * 1024) #define LOG_MAX_LINE_DUMP_SIZE (65 * 1024)
#define MAX_LOGLINE_DUMP_BUFFER_SIZE (MAX_LOGLINE_DUMP_SIZE + 10) #define LOG_MAX_LINE_DUMP_BUFFER_SIZE (LOG_MAX_LINE_DUMP_SIZE + 10)
#define MAX_LOGLINE_DUMP_CONTENT_SIZE (MAX_LOGLINE_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 TSDB_DEFAULT_LOG_BUF_SIZE (20 * 1024 * 1024) // 20MB
...@@ -383,7 +383,7 @@ void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...) { ...@@ -383,7 +383,7 @@ void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...) {
if (!osLogSpaceAvailable()) return; if (!osLogSpaceAvailable()) return;
va_list argpointer; va_list argpointer;
char buffer[MAX_LOGLINE_BUFFER_SIZE] = {0}; char buffer[LOG_MAX_LINE_BUFFER_SIZE] = {0};
int32_t len; int32_t len;
struct tm Tm, *ptm; struct tm Tm, *ptm;
struct timeval timeSecs; struct timeval timeSecs;
...@@ -398,20 +398,20 @@ void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...) { ...@@ -398,20 +398,20 @@ void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...) {
len += sprintf(buffer + len, "%s", flags); len += sprintf(buffer + len, "%s", flags);
va_start(argpointer, format); va_start(argpointer, format);
int32_t writeLen = vsnprintf(buffer + len, MAX_LOGLINE_CONTENT_SIZE, format, argpointer); int32_t writeLen = vsnprintf(buffer + len, LOG_MAX_LINE_CONTENT_SIZE, format, argpointer);
if (writeLen <= 0) { if (writeLen <= 0) {
char tmp[MAX_LOGLINE_DUMP_BUFFER_SIZE] = {0}; char tmp[LOG_MAX_LINE_DUMP_BUFFER_SIZE] = {0};
writeLen = vsnprintf(tmp, MAX_LOGLINE_DUMP_CONTENT_SIZE, format, argpointer); writeLen = vsnprintf(tmp, LOG_MAX_LINE_DUMP_CONTENT_SIZE, format, argpointer);
strncpy(buffer + len, tmp, MAX_LOGLINE_CONTENT_SIZE); strncpy(buffer + len, tmp, LOG_MAX_LINE_CONTENT_SIZE);
len += MAX_LOGLINE_CONTENT_SIZE; len += LOG_MAX_LINE_CONTENT_SIZE;
} else if (writeLen >= MAX_LOGLINE_CONTENT_SIZE) { } else if (writeLen >= LOG_MAX_LINE_CONTENT_SIZE) {
len += MAX_LOGLINE_CONTENT_SIZE; len += LOG_MAX_LINE_CONTENT_SIZE;
} else { } else {
len += writeLen; len += writeLen;
} }
va_end(argpointer); va_end(argpointer);
if (len > MAX_LOGLINE_SIZE) len = MAX_LOGLINE_SIZE; if (len > LOG_MAX_LINE_SIZE) len = LOG_MAX_LINE_SIZE;
buffer[len++] = '\n'; buffer[len++] = '\n';
buffer[len] = 0; buffer[len] = 0;
...@@ -460,7 +460,7 @@ void taosPrintLongString(const char *flags, int32_t dflag, const char *format, . ...@@ -460,7 +460,7 @@ void taosPrintLongString(const char *flags, int32_t dflag, const char *format, .
if (!osLogSpaceAvailable()) return; if (!osLogSpaceAvailable()) return;
va_list argpointer; va_list argpointer;
char buffer[MAX_LOGLINE_DUMP_BUFFER_SIZE]; char buffer[LOG_MAX_LINE_DUMP_BUFFER_SIZE];
int32_t len; int32_t len;
struct tm Tm, *ptm; struct tm Tm, *ptm;
struct timeval timeSecs; struct timeval timeSecs;
...@@ -475,10 +475,10 @@ void taosPrintLongString(const char *flags, int32_t dflag, const char *format, . ...@@ -475,10 +475,10 @@ void taosPrintLongString(const char *flags, int32_t dflag, const char *format, .
len += sprintf(buffer + len, "%s", flags); len += sprintf(buffer + len, "%s", flags);
va_start(argpointer, format); va_start(argpointer, format);
len += vsnprintf(buffer + len, MAX_LOGLINE_DUMP_CONTENT_SIZE, format, argpointer); len += vsnprintf(buffer + len, LOG_MAX_LINE_DUMP_CONTENT_SIZE, format, argpointer);
va_end(argpointer); va_end(argpointer);
if (len > MAX_LOGLINE_DUMP_SIZE) len = MAX_LOGLINE_DUMP_SIZE; if (len > LOG_MAX_LINE_DUMP_SIZE) len = LOG_MAX_LINE_DUMP_SIZE;
buffer[len++] = '\n'; buffer[len++] = '\n';
buffer[len] = 0; buffer[len] = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册