mirror of
https://github.com/taosdata/TDengine
synced 2026-05-24 10:09:01 +00:00
* feat: support TDAcoreOS * chore: cmake options for TD_ACORE * chore: disable lemon for TD_ACORE * chore: add lzma2 and msvcregex * chore: cmake for lzma2 * chore: adapt for TD_ACORE * chore: adapt strcasecmp for TD_ACORE * chore: adapt for geos/threadName * chore: build adapt for TD_ACORE * chore: build adapt for TD_ACORE * chore: build adapt for TD_ACORE * chore: build adapt for TD_ACORE * chore: build adapt for TD_ACORE termio * chore: refact transComm.h for TD_ACORE * chore: refact transportInt.h for TD_ACORE * chore: refact trans.c for TD_ACORE * chore: refact trpc.h for TD_ACORE * chore: refact transCli.c/transComm.c/transSvr.c for TD_ACORE * chore: refact uv.h for TD_ACORE * chore: refact geosWrapper.h for TD_ACORE * chore: refact token/builtins/udf for TD_ACORE * chore: refact rocks for TD_ACORE * chore: refact tsdbCache.c for TD_ACORE, use LRU cache for last/last_row, not use rocksdb * chore: refact FAIL to _ERR to solve conflicts for TD_ACORE * chore: restore lemon.c/lempar.c * chore: support build lemon for TD_ACORE * chore: refact trpc and siginfo_t for TD_ACORE * chore: refact timezone for TD_ACORE * chore: refact lz4 for TD_ACORE * chore: refact TD_ACORE to make compile pass * chore: code optimization for TD_ASTRA * feat: support run taos with taosd integrated * feat: support invoke taos shell * feat: support invoke taos shell * feat: support invoke taos shell * chore: code optimization * chore: fix undefined reference problem os TD_ASTRA * chore: resolve compile problem for TD_ASTRA * chore: fix undefined reference problem os TD_ASTRA * chore: fix undefined reference problem os TD_ASTRA * chore: fix undefined reference problem os TD_ASTRA * chore: fix undefined reference problem os TD_ASTRA * chore: fix undefined reference problem os TD_ASTRA * chore: fix undefined reference problem os TD_ASTRA * chore: fix undefined reference problem os TD_ASTRA * chore: fix undefined reference problem os TD_ASTRA * chore: fix undefined reference problem os TD_ASTRA * chore: fix undefined reference problem os TD_ASTRA * chore: fix undefined reference problem os TD_ASTRA * chore: fix undefined reference problem os TD_ASTRA * chore: fix undefined reference problem os TD_ASTRA * chore: fix undefined reference problem os TD_ASTRA * chore: fix undefined reference problem os TD_ASTRA * chore: fix undefined reference problem os TD_ASTRA * chore: fix undefined reference problem os TD_ASTRA * chore: fix undefined reference problem os TD_ASTRA * chore: fix getpid * chore: fix typo * chore: set stack size and ajust min pack size for TD_ASTRA * chore: fix pthread create parameters * chore: chmod adapt for TD_ASTRA * chore: fix trans compile problem * chore: adapt chmod for TD_ASTRA * chore: byte alignment for TD_ASTRA * chore: more code for adaption of TD_ASTRA * chore: more code for adaption of TD_ASTRA * chore: more code for adaption of TD_ASTRA * chore: byte alignment for TD_ASTRA * chore: conditional compile option * chore: adapt for TD_ASTRA * chore: adjust taosPId and msvcregex for TD_ASTRA * chore: log dir separator for wal build name * chore: fix type of pointer parameter * chore: fix compile problem of tsdbGetS3Size * enh: get last ver from wal log for TD_ASTRA * enh: refact wal meta ver * enh: refact wal meta ver * fix: typo of taosUcs4Compare * enh: process return value of CI * chore: more code for TD_ASTRA adaption * chore: return value of taosCloseFile in walMeta.c * chore: fix compile problem * chore: fix compile problem of TD_ASTRA * fix: update macro for tq and stream task * chore: code optimization for TD_ASTRA * chore: restore create log and init cfg interface * chore: restore strncasecmp and strcasecmp * fix: adjust the field position of SDataBlockInfo * fix: pragma pack min size * fix: pragma pack min size * chore: more code for TD_ASTRA adaption * fix: type of parameters * chore: adapt strncasecmp and strcasecmp for TD_ASTRA * chore: restore interface of init log * enh: pack push optimization * fix: taos init cfg * add astra support * fix: fetch the value of suid * chore: switch of build with udf * add temp code * chore: more code for TD_ASTRA adaption * chore: add macro ERRNO to replace errno * chore: bytes align for TD_ASTRA * fix: remove obsolete codes * enh: support USE_UDF macro * fix compile error * fix: resolve redefinition problem * fix: compile problem of log.cpp * fix: compile problem of osTimezone * fix: resolve compile problem of udf * fix: pragma definition on windows * fix: ucs4 and stpncpy for TD_ASTRA * fix: memory align problem for TD_ASTRA * enh: solve memory leak for TD_ASTRA_RPC * fix: compile problem of taosSetInt64Aligned * fix: restore mndSubscribe.c * fix: scalar for udf * chore: code adaption for TD_ASTRA * chore: code optimization for TD_ASTRA * fix: typo of add definition * fix: typo of macro in tudf.h * chore: remove void to make CI pass * enh: move macro from cmake.platform to cmake.options * enh: byte align for hash node and error code * chore: restore the size for lru cache * enh: restore some code about pack push * chore: restore the pack push in tmsg.h * fix: add macro of pack pop for windows --------- Co-authored-by: yihaoDeng <luomoxyz@126.com>
154 lines
5.4 KiB
C
154 lines
5.4 KiB
C
/*
|
|
* 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_LOG_H_
|
|
#define _TD_UTIL_LOG_H_
|
|
|
|
#include "os.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef enum {
|
|
DEBUG_FATAL = 1,
|
|
DEBUG_ERROR = 1,
|
|
DEBUG_WARN = 2,
|
|
DEBUG_INFO = 2,
|
|
DEBUG_DEBUG = 4,
|
|
DEBUG_TRACE = 8,
|
|
DEBUG_DUMP = 16,
|
|
DEBUG_SCREEN = 64,
|
|
DEBUG_FILE = 128
|
|
} ELogLevel;
|
|
|
|
typedef enum {
|
|
LOG_MODE_TAOSC = 1,
|
|
LOG_MODE_TAOSD = 2
|
|
} ELogMode;
|
|
|
|
typedef void (*LogFp)(int64_t ts, ELogLevel level, const char *content);
|
|
|
|
extern bool tsLogEmbedded;
|
|
extern bool tsAsyncLog;
|
|
extern bool tsAssert;
|
|
extern int32_t tsNumOfLogLines;
|
|
extern int32_t tsLogKeepDays;
|
|
extern char *tsLogOutput;
|
|
extern LogFp tsLogFp;
|
|
extern int64_t tsNumOfErrorLogs;
|
|
extern int64_t tsNumOfInfoLogs;
|
|
extern int64_t tsNumOfDebugLogs;
|
|
extern int64_t tsNumOfTraceLogs;
|
|
extern int32_t dDebugFlag;
|
|
extern int32_t vDebugFlag;
|
|
extern int32_t mDebugFlag;
|
|
extern int32_t cDebugFlag;
|
|
extern int32_t jniDebugFlag;
|
|
extern int32_t tmrDebugFlag;
|
|
extern int32_t uDebugFlag;
|
|
extern int32_t rpcDebugFlag;
|
|
extern int32_t qDebugFlag;
|
|
extern int32_t stDebugFlag;
|
|
extern int32_t wDebugFlag;
|
|
extern int32_t azDebugFlag;
|
|
extern int32_t sDebugFlag;
|
|
extern int32_t tsdbDebugFlag;
|
|
extern int32_t tqDebugFlag;
|
|
extern int32_t fsDebugFlag;
|
|
extern int32_t metaDebugFlag;
|
|
extern int32_t udfDebugFlag;
|
|
extern int32_t smaDebugFlag;
|
|
extern int32_t idxDebugFlag;
|
|
extern int32_t tdbDebugFlag;
|
|
extern int32_t sndDebugFlag;
|
|
extern int32_t simDebugFlag;
|
|
|
|
extern int32_t tqClientDebugFlag;
|
|
int32_t taosInitLogOutput(const char **ppLogName);
|
|
int32_t taosInitLog(const char *logName, int32_t maxFiles, bool tsc);
|
|
void taosCloseLog();
|
|
void taosResetLog();
|
|
void taosDumpData(uint8_t *msg, int32_t len);
|
|
void taosSetNoNewFile();
|
|
|
|
// Fast uint64_t to string conversion, equivalent to sprintf(buf, "%lu", val) but with 10x better performance.
|
|
char *u64toaFastLut(uint64_t val, char *buf);
|
|
|
|
void taosPrintLog(const char *flags, int32_t level, int32_t dflag, const char *format, ...)
|
|
#ifdef __GNUC__
|
|
__attribute__((format(printf, 4, 5)))
|
|
#endif
|
|
;
|
|
|
|
void taosPrintLongString(const char *flags, int32_t level, int32_t dflag, const char *format, ...)
|
|
#ifdef __GNUC__
|
|
__attribute__((format(printf, 4, 5)))
|
|
#endif
|
|
;
|
|
|
|
void taosPrintSlowLog(const char *format, ...)
|
|
#ifdef __GNUC__
|
|
__attribute__((format(printf, 1, 2)))
|
|
#endif
|
|
;
|
|
|
|
bool taosAssertDebug(bool condition, const char *file, int32_t line, bool core, const char *format, ...);
|
|
bool taosAssertRelease(bool condition);
|
|
|
|
// Disable all asserts that may compromise the performance.
|
|
#if defined DISABLE_ASSERT
|
|
#define ASSERT(condition)
|
|
#define ASSERTS(condition, ...) (0)
|
|
#else
|
|
#define ASSERT_CORE(condition, ...) \
|
|
((condition) ? false : taosAssertDebug(condition, __FILE__, __LINE__, 1, __VA_ARGS__))
|
|
#define ASSERTS(condition, ...) ((condition) ? false : taosAssertDebug(condition, __FILE__, __LINE__, 0, __VA_ARGS__))
|
|
#ifdef NDEBUG
|
|
#define ASSERT(condition) taosAssertRelease(condition)
|
|
#else
|
|
#define ASSERT(condition) ASSERTS(condition, "assert info not provided")
|
|
#endif
|
|
#endif
|
|
|
|
void taosLogCrashInfo(char *nodeType, char *pMsg, int64_t msgLen, int signum, void *sigInfo);
|
|
void taosReadCrashInfo(char *filepath, char **pMsg, int64_t *pMsgLen, TdFilePtr *pFd);
|
|
void taosReleaseCrashLogFile(TdFilePtr pFile, bool truncateFile);
|
|
|
|
int32_t initCrashLogWriter();
|
|
void checkAndPrepareCrashInfo();
|
|
bool reportThreadSetQuit();
|
|
void writeCrashLogToFile(int signum, void *sigInfo, char *nodeType, int64_t clusterId, int64_t startTime);
|
|
|
|
// clang-format off
|
|
#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL ", DEBUG_FATAL, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
|
#define uError(...) { if (uDebugFlag & DEBUG_ERROR) { taosPrintLog("UTL ERROR ", DEBUG_ERROR, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
|
#define uWarn(...) { if (uDebugFlag & DEBUG_WARN) { taosPrintLog("UTL WARN ", DEBUG_WARN, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
|
#define uInfo(...) { if (uDebugFlag & DEBUG_INFO) { taosPrintLog("UTL INFO ", DEBUG_INFO, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
|
#define uDebug(...) { if (uDebugFlag & DEBUG_DEBUG) { taosPrintLog("UTL DEBUG ", DEBUG_DEBUG, uDebugFlag, __VA_ARGS__); }}
|
|
#define uTrace(...) { if (uDebugFlag & DEBUG_TRACE) { taosPrintLog("UTL TRACE ", DEBUG_TRACE, uDebugFlag, __VA_ARGS__); }}
|
|
#define uDebugL(...){ if (uDebugFlag & DEBUG_DEBUG) { taosPrintLongString("UTL DEBUG ", DEBUG_DEBUG, uDebugFlag, __VA_ARGS__); }}
|
|
#define uInfoL(...) { if (uDebugFlag & DEBUG_INFO) { taosPrintLongString("UTL INFO ", DEBUG_INFO, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
|
|
|
|
#define pError(...) { taosPrintLog("APP ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }
|
|
#define pPrint(...) { taosPrintLog("APP INFO ", DEBUG_INFO, 255, __VA_ARGS__); }
|
|
// clang-format on
|
|
|
|
// #define BUF_PAGE_DEBUG
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /*_TD_UTIL_LOG_H_*/
|