提交 460f7890 编写于 作者: S Shengliang Guan

log variables

上级 06a7ba7b
...@@ -23,7 +23,7 @@ extern "C" { ...@@ -23,7 +23,7 @@ extern "C" {
#endif #endif
// log // log
extern int8_t tsAsyncLog; extern bool tsAsyncLog;
extern int32_t tsNumOfLogLines; extern int32_t tsNumOfLogLines;
extern int32_t tsLogKeepDays; extern int32_t tsLogKeepDays;
extern int32_t dDebugFlag; extern int32_t dDebugFlag;
...@@ -32,9 +32,6 @@ extern int32_t mDebugFlag; ...@@ -32,9 +32,6 @@ extern int32_t mDebugFlag;
extern int32_t cDebugFlag; extern int32_t cDebugFlag;
extern int32_t jniDebugFlag; extern int32_t jniDebugFlag;
extern int32_t tmrDebugFlag; extern int32_t tmrDebugFlag;
extern int32_t httpDebugFlag;
extern int32_t mqttDebugFlag;
extern int32_t monDebugFlag;
extern int32_t uDebugFlag; extern int32_t uDebugFlag;
extern int32_t rpcDebugFlag; extern int32_t rpcDebugFlag;
extern int32_t qDebugFlag; extern int32_t qDebugFlag;
...@@ -42,8 +39,7 @@ extern int32_t wDebugFlag; ...@@ -42,8 +39,7 @@ extern int32_t wDebugFlag;
extern int32_t sDebugFlag; extern int32_t sDebugFlag;
extern int32_t tsdbDebugFlag; extern int32_t tsdbDebugFlag;
extern int32_t tqDebugFlag; extern int32_t tqDebugFlag;
extern int32_t cqDebugFlag; extern int32_t fsDebugFlag;
extern int32_t debugFlag;
#define DEBUG_FATAL 1U #define DEBUG_FATAL 1U
#define DEBUG_ERROR DEBUG_FATAL #define DEBUG_ERROR DEBUG_FATAL
...@@ -56,7 +52,7 @@ extern int32_t debugFlag; ...@@ -56,7 +52,7 @@ extern int32_t debugFlag;
#define DEBUG_SCREEN 64U #define DEBUG_SCREEN 64U
#define DEBUG_FILE 128U #define DEBUG_FILE 128U
int32_t taosInitLog(char *logName, int32_t numOfLogLines, int32_t maxFiles); int32_t taosInitLog(const char *logName, int32_t maxFiles);
void taosCloseLog(); void taosCloseLog();
void taosResetLog(); void taosResetLog();
...@@ -75,7 +71,7 @@ void taosPrintLongString(const char *flags, int32_t dflag, const char *format, . ...@@ -75,7 +71,7 @@ void taosPrintLongString(const char *flags, int32_t dflag, const char *format, .
void taosDumpData(unsigned char *msg, int32_t len); void taosDumpData(unsigned char *msg, int32_t len);
void taosSetDebugFlag(int32_t flag); void taosSetAllDebugFlag(int32_t flag);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -82,9 +82,7 @@ static void tscInitLogFile() { ...@@ -82,9 +82,7 @@ static void tscInitLogFile() {
const char *defaultLogFileNamePrefix = "taoslog"; const char *defaultLogFileNamePrefix = "taoslog";
const int32_t maxLogFileNum = 10; const int32_t maxLogFileNum = 10;
char temp[128] = {0}; if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
sprintf(temp, "%s/%s", tsLogDir, defaultLogFileNamePrefix);
if (taosInitLog(temp, tsNumOfLogLines, maxLogFileNum) < 0) {
printf("failed to open log file in directory:%s\n", tsLogDir); printf("failed to open log file in directory:%s\n", tsLogDir);
} }
#endif #endif
......
...@@ -178,22 +178,6 @@ char *qtypeStr[] = {"rpc", "fwd", "wal", "cq", "query"}; ...@@ -178,22 +178,6 @@ char *qtypeStr[] = {"rpc", "fwd", "wal", "cq", "query"};
static pthread_once_t tsInitGlobalCfgOnce = PTHREAD_ONCE_INIT; static pthread_once_t tsInitGlobalCfgOnce = PTHREAD_ONCE_INIT;
void taosSetAllDebugFlag() {
if (debugFlag != 0) {
mDebugFlag = debugFlag;
dDebugFlag = debugFlag;
vDebugFlag = debugFlag;
jniDebugFlag = debugFlag;
qDebugFlag = debugFlag;
rpcDebugFlag = debugFlag;
uDebugFlag = debugFlag;
sDebugFlag = debugFlag;
wDebugFlag = debugFlag;
tsdbDebugFlag = debugFlag;
cqDebugFlag = debugFlag;
uInfo("all debug flag are set to %d", debugFlag);
}
}
int32_t taosCfgDynamicOptions(char *msg) { int32_t taosCfgDynamicOptions(char *msg) {
#if 0 #if 0
......
...@@ -19,25 +19,24 @@ ...@@ -19,25 +19,24 @@
#include "config.h" #include "config.h"
#include "dnode.h" #include "dnode.h"
#include "taoserror.h"
#include "tglobal.h" #include "tglobal.h"
#include "ulog.h" #include "ulog.h"
#include "taoserror.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
int32_t dmnInitLogCfg(SConfig *pCfg); int32_t dmnAddLogCfg(SConfig *pCfg);
int32_t dmnInitLog(const char *cfgDir, const char *envFile, const char *apolloUrl); int32_t dmnInitLog(const char *cfgDir, const char *envFile, const char *apolloUrl);
int32_t dmnLoadCfg(SConfig *pConfig, const char *inputCfgDir, const char *envFile, const char *apolloUrl);
int32_t dmnLoadCfg(SConfig *pConfig, const char *inputCfgDir, const char *envFile, const char *apolloUrl); SConfig *dmnReadCfg(const char *cfgDir, const char *envFile, const char *apolloUrl);
SConfig *dmnReadCfg(const char *cfgDir, const char *envFile, const char *apolloUrl);
SDnodeEnvCfg dmnGetEnvCfg(SConfig *pCfg); SDnodeEnvCfg dmnGetEnvCfg(SConfig *pCfg);
SDnodeObjCfg dmnGetObjCfg(SConfig *pCfg); SDnodeObjCfg dmnGetObjCfg(SConfig *pCfg);
void dmnDumpCfg(SConfig *pCfg); void dmnDumpCfg(SConfig *pCfg);
void dmnPrintVersion(SConfig *pCfg); void dmnPrintVersion();
void dmnGenerateGrant(); void dmnGenerateGrant();
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -22,7 +22,6 @@ static struct { ...@@ -22,7 +22,6 @@ static struct {
bool generateGrant; bool generateGrant;
bool printAuth; bool printAuth;
bool printVersion; bool printVersion;
char configDir[PATH_MAX];
char envFile[PATH_MAX]; char envFile[PATH_MAX];
char apolloUrl[PATH_MAX]; char apolloUrl[PATH_MAX];
} dmn = {0}; } dmn = {0};
...@@ -48,8 +47,6 @@ static void dmnWaitSignal() { ...@@ -48,8 +47,6 @@ static void dmnWaitSignal() {
} }
static int32_t dmnParseOption(int32_t argc, char const *argv[]) { static int32_t dmnParseOption(int32_t argc, char const *argv[]) {
tstrncpy(dmn.configDir, "/etc/taos", PATH_MAX);
for (int32_t i = 1; i < argc; ++i) { for (int32_t i = 1; i < argc; ++i) {
if (strcmp(argv[i], "-c") == 0) { if (strcmp(argv[i], "-c") == 0) {
if (i < argc - 1) { if (i < argc - 1) {
...@@ -57,7 +54,7 @@ static int32_t dmnParseOption(int32_t argc, char const *argv[]) { ...@@ -57,7 +54,7 @@ static int32_t dmnParseOption(int32_t argc, char const *argv[]) {
printf("config file path overflow"); printf("config file path overflow");
return -1; return -1;
} }
tstrncpy(dmn.configDir, argv[i], PATH_MAX); tstrncpy(configDir, argv[i], PATH_MAX);
} else { } else {
printf("'-c' requires a parameter, default is %s\n", configDir); printf("'-c' requires a parameter, default is %s\n", configDir);
return -1; return -1;
...@@ -105,26 +102,25 @@ int main(int argc, char const *argv[]) { ...@@ -105,26 +102,25 @@ int main(int argc, char const *argv[]) {
} }
if (dmn.generateGrant) { if (dmn.generateGrant) {
dmnGenerateGrant(); dmnGenerateGrant();
return 0; return 0;
}
if (dmn.printVersion) {
dmnPrintVersion();
return 0;
} }
if (dmnInitLog(dmn.configDir, dmn.envFile, dmn.apolloUrl) != 0) { if (dmnInitLog(configDir, dmn.envFile, dmn.apolloUrl) != 0) {
return -1; return -1;
} }
SConfig *pCfg = dmnReadCfg(dmn.configDir, dmn.envFile, dmn.apolloUrl); SConfig *pCfg = dmnReadCfg(configDir, dmn.envFile, dmn.apolloUrl);
if (pCfg == NULL) { if (pCfg == NULL) {
uInfo("Failed to start TDengine since read config error"); uInfo("Failed to start TDengine since read config error");
return -1; return -1;
} }
if (dmn.printVersion) {
dmnPrintVersion(pCfg);
cfgCleanup(pCfg);
return 0;
}
if (dmn.dumpConfig) { if (dmn.dumpConfig) {
dmnDumpCfg(pCfg); dmnDumpCfg(pCfg);
cfgCleanup(pCfg); cfgCleanup(pCfg);
......
...@@ -16,91 +16,72 @@ ...@@ -16,91 +16,72 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "dmnInt.h" #include "dmnInt.h"
static int32_t dmnInitDnodeCfg(SConfig *pConfig) { static int32_t dmnAddDnodeCfg(SConfig *pCfg) {
if (cfgAddString(pConfig, "version", version) != 0) return -1; if (cfgAddString(pCfg, "buildinfo", buildinfo) != 0) return -1;
if (cfgAddString(pConfig, "buildinfo", buildinfo) != 0) return -1; if (cfgAddString(pCfg, "gitinfo", gitinfo) != 0) return -1;
if (cfgAddString(pConfig, "gitinfo", gitinfo) != 0) return -1; if (cfgAddString(pCfg, "version", version) != 0) return -1;
if (cfgAddTimezone(pConfig, "timezone", "") != 0) return -1; if (cfgAddString(pCfg, "firstEp", "") != 0) return -1;
if (cfgAddLocale(pConfig, "locale", "") != 0) return -1; if (cfgAddString(pCfg, "secondEp", "") != 0) return -1;
if (cfgAddCharset(pConfig, "charset", "") != 0) return -1; if (cfgAddString(pCfg, "fqdn", "") != 0) return -1;
if (cfgAddInt32(pConfig, "numOfCores", 1, 1, 100000) != 0) return -1; if (cfgAddInt32(pCfg, "serverPort", 6030, 1, 65056) != 0) return -1;
if (cfgAddInt32(pConfig, "numOfCommitThreads", 4, 1, 1000) != 0) return -1; if (cfgAddDir(pCfg, "dataDir", tsDataDir) != 0) return -1;
if (cfgAddBool(pConfig, "telemetryReporting", 0) != 0) return -1; if (cfgAddTimezone(pCfg, "timezone", "") != 0) return -1;
if (cfgAddBool(pConfig, "enableCoreFile", 0) != 0) return -1; if (cfgAddLocale(pCfg, "locale", "") != 0) return -1;
if (cfgAddInt32(pConfig, "supportVnodes", 256, 0, 65536) != 0) return -1; if (cfgAddCharset(pCfg, "charset", "") != 0) return -1;
if (cfgAddInt32(pConfig, "statusInterval", 1, 1, 30) != 0) return -1; if (cfgAddInt32(pCfg, "numOfCores", 1, 1, 100000) != 0) return -1;
if (cfgAddFloat(pConfig, "numOfThreadsPerCore", 1, 0, 10) != 0) return -1; if (cfgAddInt32(pCfg, "numOfCommitThreads", 4, 1, 1000) != 0) return -1;
if (cfgAddFloat(pConfig, "ratioOfQueryCores", 1, 0, 5) != 0) return -1; if (cfgAddBool(pCfg, "telemetryReporting", 0) != 0) return -1;
if (cfgAddInt32(pConfig, "maxShellConns", 50000, 10, 50000000) != 0) return -1; if (cfgAddBool(pCfg, "enableCoreFile", 0) != 0) return -1;
if (cfgAddInt32(pConfig, "shellActivityTimer", 3, 1, 120) != 0) return -1; if (cfgAddInt32(pCfg, "supportVnodes", 256, 0, 65536) != 0) return -1;
if (cfgAddInt32(pConfig, "serverPort", 6030, 1, 65056) != 0) return -1; if (cfgAddInt32(pCfg, "statusInterval", 1, 1, 30) != 0) return -1;
if (cfgAddFloat(pCfg, "numOfThreadsPerCore", 1, 0, 10) != 0) return -1;
if (cfgAddFloat(pCfg, "ratioOfQueryCores", 1, 0, 5) != 0) return -1;
if (cfgAddInt32(pCfg, "maxShellConns", 50000, 10, 50000000) != 0) return -1;
if (cfgAddInt32(pCfg, "shellActivityTimer", 3, 1, 120) != 0) return -1;
return 0; return 0;
} }
int32_t dmnLoadCfg(SConfig *pConfig, const char *inputCfgDir, const char *envFile, const char *apolloUrl) { int32_t dmnCheckCfg(SConfig *pCfg) {
char configDir[PATH_MAX] = {0}; bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
char configFile[PATH_MAX + 100] = {0}; taosSetCoreDump(enableCore);
taosExpandDir(inputCfgDir, configDir, PATH_MAX);
snprintf(configFile, sizeof(configFile), "%s" TD_DIRSEP "taos.cfg", configDir);
if (cfgLoad(pConfig, CFG_STYPE_APOLLO_URL, apolloUrl) != 0) {
uError("failed to load from apollo url:%s since %s\n", apolloUrl, terrstr());
return -1;
}
if (cfgLoad(pConfig, CFG_STYPE_CFG_FILE, configFile) != 0) {
if (cfgLoad(pConfig, CFG_STYPE_CFG_FILE, configDir) != 0) {
uError("failed to load from config file:%s since %s\n", configFile, terrstr());
return -1;
}
}
if (cfgLoad(pConfig, CFG_STYPE_ENV_FILE, envFile) != 0) {
uError("failed to load from env file:%s since %s\n", envFile, terrstr());
return -1;
}
if (cfgLoad(pConfig, CFG_STYPE_ENV_VAR, NULL) != 0) {
uError("failed to load from global env variables since %s\n", terrstr());
return -1;
}
return 0; return 0;
} }
SConfig *dmnReadCfg(const char *cfgDir, const char *envFile, const char *apolloUrl) { SConfig *dmnReadCfg(const char *cfgDir, const char *envFile, const char *apolloUrl) {
SConfig *pConfig = cfgInit(); SConfig *pCfg = cfgInit();
if (pConfig == NULL) return NULL; if (pCfg == NULL) return NULL;
if (dmnInitLogCfg(pConfig) != 0) { if (dmnAddLogCfg(pCfg) != 0) {
uError("failed to init log cfg since %s", terrstr()); printf("failed to add log cfg since %s\n", terrstr());
cfgCleanup(pConfig); cfgCleanup(pCfg);
return NULL; return NULL;
} }
if (dmnInitDnodeCfg(pConfig) != 0) { if (dmnAddDnodeCfg(pCfg) != 0) {
uError("failed to init dnode cfg since %s", terrstr()); uError("failed to init dnode cfg since %s", terrstr());
cfgCleanup(pConfig); cfgCleanup(pCfg);
return NULL; return NULL;
} }
if (dmnLoadCfg(pConfig, cfgDir, envFile, apolloUrl) != 0) { if (dmnLoadCfg(pCfg, cfgDir, envFile, apolloUrl) != 0) {
uError("failed to load cfg since %s", terrstr()); uError("failed to load cfg since %s", terrstr());
cfgCleanup(pConfig); cfgCleanup(pCfg);
return NULL; return NULL;
} }
bool enableCore = cfgGetItem(pConfig, "enableCoreFile")->bval; if (dmnCheckCfg(pCfg) != 0) {
taosSetCoreDump(enableCore); uError("failed to check cfg since %s", terrstr());
}
if (taosCheckAndPrintCfg() != 0) { if (taosCheckAndPrintCfg() != 0) {
uError("failed to check config"); uError("failed to check config");
return NULL; return NULL;
} }
return pCfg;
return pConfig;
} }
void dmnDumpCfg(SConfig *pCfg) { void dmnDumpCfg(SConfig *pCfg) {
...@@ -146,7 +127,7 @@ SDnodeEnvCfg dmnGetEnvCfg(SConfig *pCfg) { ...@@ -146,7 +127,7 @@ SDnodeEnvCfg dmnGetEnvCfg(SConfig *pCfg) {
tstrncpy(envCfg.locale, cfgGetItem(pCfg, "locale")->str, sizeof(envCfg.locale)); tstrncpy(envCfg.locale, cfgGetItem(pCfg, "locale")->str, sizeof(envCfg.locale));
tstrncpy(envCfg.charset, cfgGetItem(pCfg, "charset")->str, sizeof(envCfg.charset)); tstrncpy(envCfg.charset, cfgGetItem(pCfg, "charset")->str, sizeof(envCfg.charset));
envCfg.numOfCores = cfgGetItem(pCfg, "numOfCores")->i32; envCfg.numOfCores = cfgGetItem(pCfg, "numOfCores")->i32;
envCfg.numOfCommitThreads = (uint16_t) cfgGetItem(pCfg, "numOfCommitThreads")->i32; envCfg.numOfCommitThreads = (uint16_t)cfgGetItem(pCfg, "numOfCommitThreads")->i32;
envCfg.enableTelem = cfgGetItem(pCfg, "telemetryReporting")->bval; envCfg.enableTelem = cfgGetItem(pCfg, "telemetryReporting")->bval;
return envCfg; return envCfg;
......
...@@ -16,25 +16,52 @@ ...@@ -16,25 +16,52 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "dmnInt.h" #include "dmnInt.h"
int32_t dmnInitLogCfg(SConfig *pCfg) { int32_t dmnAddLogCfg(SConfig *pCfg) {
if (cfgAddDir(pCfg, "logDir", "/var/log/taos") != 0) return -1; if (cfgAddDir(pCfg, "logDir", "/var/log/taos") != 0) return -1;
if (cfgAddBool(pCfg, "asyncLog", 1) != 0) return -1;
if (cfgAddInt32(pCfg, "numOfLogLines", 10000000, 1000, 2000000000) != 0) return -1; if (cfgAddInt32(pCfg, "numOfLogLines", 10000000, 1000, 2000000000) != 0) return -1;
if (cfgAddInt32(pCfg, "logKeepDays", 0, -365000, 365000) != 0) return -1; if (cfgAddInt32(pCfg, "logKeepDays", 0, -365000, 365000) != 0) return -1;
if (cfgAddBool(pCfg, "asyncLog", 1) != 0) return -1;
if (cfgAddInt32(pCfg, "debugFlag", 0, 0, 255) != 0) return -1; if (cfgAddInt32(pCfg, "debugFlag", 0, 0, 255) != 0) return -1;
if (cfgAddInt32(pCfg, "mDebugFlag", 0, 0, 255) != 0) return -1;
if (cfgAddInt32(pCfg, "dDebugFlag", 0, 0, 255) != 0) return -1; if (cfgAddInt32(pCfg, "dDebugFlag", 0, 0, 255) != 0) return -1;
if (cfgAddInt32(pCfg, "sDebugFlag", 0, 0, 255) != 0) return -1; if (cfgAddInt32(pCfg, "vDebugFlag", 0, 0, 255) != 0) return -1;
if (cfgAddInt32(pCfg, "wDebugFlag", 0, 0, 255) != 0) return -1; if (cfgAddInt32(pCfg, "mDebugFlag", 0, 0, 255) != 0) return -1;
if (cfgAddInt32(pCfg, "rpcDebugFlag", 0, 0, 255) != 0) return -1;
if (cfgAddInt32(pCfg, "tmrDebugFlag", 0, 0, 255) != 0) return -1;
if (cfgAddInt32(pCfg, "cDebugFlag", 0, 0, 255) != 0) return -1; if (cfgAddInt32(pCfg, "cDebugFlag", 0, 0, 255) != 0) return -1;
if (cfgAddInt32(pCfg, "jniDebugFlag", 0, 0, 255) != 0) return -1; if (cfgAddInt32(pCfg, "jniDebugFlag", 0, 0, 255) != 0) return -1;
if (cfgAddInt32(pCfg, "tmrDebugFlag", 0, 0, 255) != 0) return -1;
if (cfgAddInt32(pCfg, "uDebugFlag", 0, 0, 255) != 0) return -1; if (cfgAddInt32(pCfg, "uDebugFlag", 0, 0, 255) != 0) return -1;
if (cfgAddInt32(pCfg, "rpcDebugFlag", 0, 0, 255) != 0) return -1;
if (cfgAddInt32(pCfg, "qDebugFlag", 0, 0, 255) != 0) return -1; if (cfgAddInt32(pCfg, "qDebugFlag", 0, 0, 255) != 0) return -1;
if (cfgAddInt32(pCfg, "vDebugFlag", 0, 0, 255) != 0) return -1; if (cfgAddInt32(pCfg, "wDebugFlag", 0, 0, 255) != 0) return -1;
if (cfgAddInt32(pCfg, "sDebugFlag", 0, 0, 255) != 0) return -1;
if (cfgAddInt32(pCfg, "tsdbDebugFlag", 0, 0, 255) != 0) return -1; if (cfgAddInt32(pCfg, "tsdbDebugFlag", 0, 0, 255) != 0) return -1;
if (cfgAddInt32(pCfg, "cqDebugFlag", 0, 0, 255) != 0) return -1; if (cfgAddInt32(pCfg, "tqDebugFlag", 0, 0, 255) != 0) return -1;
if (cfgAddInt32(pCfg, "fsDebugFlag", 0, 0, 255) != 0) return -1;
return 0;
}
int32_t dmnSetLogCfg(SConfig *pCfg) {
tstrncpy(tsLogDir, cfgGetItem(pCfg, "logDir")->str, PATH_MAX);
tsAsyncLog = cfgGetItem(pCfg, "asyncLog")->bval;
tsNumOfLogLines = cfgGetItem(pCfg, "numOfLogLines")->i32;
tsLogKeepDays = cfgGetItem(pCfg, "logKeepDays")->i32;
dDebugFlag = cfgGetItem(pCfg, "dDebugFlag")->i32;
vDebugFlag = cfgGetItem(pCfg, "vDebugFlag")->i32;
mDebugFlag = cfgGetItem(pCfg, "mDebugFlag")->i32;
cDebugFlag = cfgGetItem(pCfg, "cDebugFlag")->i32;
jniDebugFlag = cfgGetItem(pCfg, "jniDebugFlag")->i32;
tmrDebugFlag = cfgGetItem(pCfg, "tmrDebugFlag")->i32;
uDebugFlag = cfgGetItem(pCfg, "uDebugFlag")->i32;
rpcDebugFlag = cfgGetItem(pCfg, "rpcDebugFlag")->i32;
qDebugFlag = cfgGetItem(pCfg, "qDebugFlag")->i32;
wDebugFlag = cfgGetItem(pCfg, "wDebugFlag")->i32;
sDebugFlag = cfgGetItem(pCfg, "sDebugFlag")->i32;
tsdbDebugFlag = cfgGetItem(pCfg, "tsdbDebugFlag")->i32;
tqDebugFlag = cfgGetItem(pCfg, "tqDebugFlag")->i32;
fsDebugFlag = cfgGetItem(pCfg, "fsDebugFlag")->i32;
int32_t debugFlag = cfgGetItem(pCfg, "debugFlag")->i32;
taosSetAllDebugFlag(debugFlag);
return 0; return 0;
} }
...@@ -42,22 +69,26 @@ int32_t dmnInitLog(const char *cfgDir, const char *envFile, const char *apolloUr ...@@ -42,22 +69,26 @@ int32_t dmnInitLog(const char *cfgDir, const char *envFile, const char *apolloUr
SConfig *pCfg = cfgInit(); SConfig *pCfg = cfgInit();
if (pCfg == NULL) return -1; if (pCfg == NULL) return -1;
if (dmnInitLogCfg(pCfg) != 0) { if (dmnAddLogCfg(pCfg) != 0) {
uError("failed to init log cfg since %s\n", terrstr()); printf("failed to add log cfg since %s\n", terrstr());
cfgCleanup(pCfg); cfgCleanup(pCfg);
return -1; return -1;
} }
if (dmnLoadCfg(pCfg, cfgDir, envFile, apolloUrl) != 0) { if (dmnLoadCfg(pCfg, cfgDir, envFile, apolloUrl) != 0) {
uError("failed to load log cfg since %s\n", terrstr()); printf("failed to load log cfg since %s\n", terrstr());
cfgCleanup(pCfg); cfgCleanup(pCfg);
return -1; return -1;
} }
char temp[PATH_MAX] = {0}; if (dmnSetLogCfg(pCfg) != 0) {
snprintf(temp, PATH_MAX, "%s" TD_DIRSEP "taosdlog", cfgGetItem(pCfg, "logDir")->str); printf("failed to set log cfg since %s\n", terrstr());
if (taosInitLog(temp, cfgGetItem(pCfg, "numOfLogLines")->i32, 1) != 0) { cfgCleanup(pCfg);
uError("failed to init log file since %s\n", terrstr()); return -1;
}
if (taosInitLog("taosdlog", 1) != 0) {
printf("failed to init log file since %s\n", terrstr());
cfgCleanup(pCfg); cfgCleanup(pCfg);
return -1; return -1;
} }
...@@ -65,3 +96,35 @@ int32_t dmnInitLog(const char *cfgDir, const char *envFile, const char *apolloUr ...@@ -65,3 +96,35 @@ int32_t dmnInitLog(const char *cfgDir, const char *envFile, const char *apolloUr
cfgCleanup(pCfg); cfgCleanup(pCfg);
return 0; return 0;
} }
int32_t dmnLoadCfg(SConfig *pConfig, const char *inputCfgDir, const char *envFile, const char *apolloUrl) {
char configDir[PATH_MAX] = {0};
char configFile[PATH_MAX + 100] = {0};
taosExpandDir(inputCfgDir, configDir, PATH_MAX);
snprintf(configFile, sizeof(configFile), "%s" TD_DIRSEP "taos.cfg", configDir);
if (cfgLoad(pConfig, CFG_STYPE_APOLLO_URL, apolloUrl) != 0) {
uError("failed to load from apollo url:%s since %s\n", apolloUrl, terrstr());
return -1;
}
if (cfgLoad(pConfig, CFG_STYPE_CFG_FILE, configFile) != 0) {
if (cfgLoad(pConfig, CFG_STYPE_CFG_FILE, configDir) != 0) {
uError("failed to load from config file:%s since %s\n", configFile, terrstr());
return -1;
}
}
if (cfgLoad(pConfig, CFG_STYPE_ENV_FILE, envFile) != 0) {
uError("failed to load from env file:%s since %s\n", envFile, terrstr());
return -1;
}
if (cfgLoad(pConfig, CFG_STYPE_ENV_VAR, NULL) != 0) {
uError("failed to load from global env variables since %s\n", terrstr());
return -1;
}
return 0;
}
...@@ -22,7 +22,7 @@ void dmnGenerateGrant() { ...@@ -22,7 +22,7 @@ void dmnGenerateGrant() {
#endif #endif
} }
void dmnPrintVersion(SConfig *pCfg) { void dmnPrintVersion() {
#ifdef TD_ENTERPRISE #ifdef TD_ENTERPRISE
char *releaseName = "enterprise"; char *releaseName = "enterprise";
#else #else
......
...@@ -28,16 +28,12 @@ void Testbase::InitLog(const char* path) { ...@@ -28,16 +28,12 @@ void Testbase::InitLog(const char* path) {
wDebugFlag = 0; wDebugFlag = 0;
sDebugFlag = 0; sDebugFlag = 0;
tsdbDebugFlag = 0; tsdbDebugFlag = 0;
cqDebugFlag = 0;
tscEmbeddedInUtil = 1; tscEmbeddedInUtil = 1;
tsAsyncLog = 0; tsAsyncLog = 0;
taosRemoveDir(path); taosRemoveDir(path);
taosMkDir(path); taosMkDir(path);
if (taosInitLog("taosdlog", 1) != 0) {
char temp[PATH_MAX];
snprintf(temp, PATH_MAX, "%s/taosdlog", path);
if (taosInitLog(temp, tsNumOfLogLines, 1) != 0) {
printf("failed to init log file\n"); printf("failed to init log file\n");
} }
} }
......
...@@ -131,9 +131,7 @@ void ctgTestInitLogFile() { ...@@ -131,9 +131,7 @@ void ctgTestInitLogFile() {
ctgDbgEnableDebug("api"); ctgDbgEnableDebug("api");
char temp[128] = {0}; if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
sprintf(temp, "%s/%s", tsLogDir, defaultLogFileNamePrefix);
if (taosInitLog(temp, tsNumOfLogLines, maxLogFileNum) < 0) {
printf("failed to open log file in directory:%s\n", tsLogDir); printf("failed to open log file in directory:%s\n", tsLogDir);
} }
} }
......
...@@ -538,10 +538,7 @@ void cfgPrintCfg(SConfig *pCfg) { ...@@ -538,10 +538,7 @@ void cfgPrintCfg(SConfig *pCfg) {
} }
int32_t cfgCheck(SConfig *pConfig) { int32_t cfgCheck(SConfig *pConfig) {
SConfigItem *pItem = cfgGetItem(pConfig, "debugFlag"); SConfigItem *pItem = NULL;
if (pItem != NULL) {
taosSetDebugFlag(pItem->i32);
}
pItem = cfgGetItem(pConfig, "localFqdn"); pItem = cfgGetItem(pConfig, "localFqdn");
if (pItem != NULL) { if (pItem != NULL) {
......
...@@ -101,9 +101,7 @@ void qwtInitLogFile() { ...@@ -101,9 +101,7 @@ void qwtInitLogFile() {
tsAsyncLog = 0; tsAsyncLog = 0;
qDebugFlag = 159; qDebugFlag = 159;
char temp[128] = {0}; if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
sprintf(temp, "%s/%s", tsLogDir, defaultLogFileNamePrefix);
if (taosInitLog(temp, tsNumOfLogLines, maxLogFileNum) < 0) {
printf("failed to open log file in directory:%s\n", tsLogDir); printf("failed to open log file in directory:%s\n", tsLogDir);
} }
......
...@@ -66,9 +66,7 @@ void schtInitLogFile() { ...@@ -66,9 +66,7 @@ void schtInitLogFile() {
tsAsyncLog = 0; tsAsyncLog = 0;
qDebugFlag = 159; qDebugFlag = 159;
char temp[128] = {0}; if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
sprintf(temp, "%s/%s", tsLogDir, defaultLogFileNamePrefix);
if (taosInitLog(temp, tsNumOfLogLines, maxLogFileNum) < 0) {
printf("failed to open log file in directory:%s\n", tsLogDir); printf("failed to open log file in directory:%s\n", tsLogDir);
} }
......
...@@ -192,7 +192,7 @@ int main(int argc, char *argv[]) { ...@@ -192,7 +192,7 @@ int main(int argc, char *argv[]) {
} }
} }
taosInitLog("client.log", 100000, 10); taosInitLog("client.log", 10);
void *pRpc = rpcOpen(&rpcInit); void *pRpc = rpcOpen(&rpcInit);
if (pRpc == NULL) { if (pRpc == NULL) {
......
...@@ -169,7 +169,7 @@ int main(int argc, char *argv[]) { ...@@ -169,7 +169,7 @@ int main(int argc, char *argv[]) {
tsAsyncLog = 0; tsAsyncLog = 0;
rpcInit.connType = TAOS_CONN_SERVER; rpcInit.connType = TAOS_CONN_SERVER;
taosInitLog("server.log", 100000, 10); taosInitLog("server.log", 10);
void *pRpc = rpcOpen(&rpcInit); void *pRpc = rpcOpen(&rpcInit);
if (pRpc == NULL) { if (pRpc == NULL) {
......
...@@ -169,7 +169,7 @@ int main(int argc, char *argv[]) { ...@@ -169,7 +169,7 @@ int main(int argc, char *argv[]) {
} }
} }
taosInitLog("client.log", 100000, 10); taosInitLog("client.log", 10);
void *pRpc = rpcOpen(&rpcInit); void *pRpc = rpcOpen(&rpcInit);
if (pRpc == NULL) { if (pRpc == NULL) {
......
...@@ -148,7 +148,7 @@ int main(int argc, char *argv[]) { ...@@ -148,7 +148,7 @@ int main(int argc, char *argv[]) {
} }
} }
taosInitLog("client.log", 100000, 10); taosInitLog("client.log", 10);
void *pRpc = rpcOpen(&rpcInit); void *pRpc = rpcOpen(&rpcInit);
if (pRpc == NULL) { if (pRpc == NULL) {
......
...@@ -158,7 +158,7 @@ int main(int argc, char *argv[]) { ...@@ -158,7 +158,7 @@ int main(int argc, char *argv[]) {
tsAsyncLog = 0; tsAsyncLog = 0;
rpcInit.connType = TAOS_CONN_SERVER; rpcInit.connType = TAOS_CONN_SERVER;
taosInitLog("server.log", 100000, 10); taosInitLog("server.log", 10);
void *pRpc = rpcOpen(&rpcInit); void *pRpc = rpcOpen(&rpcInit);
if (pRpc == NULL) { if (pRpc == NULL) {
......
...@@ -170,7 +170,7 @@ int main(int argc, char *argv[]) { ...@@ -170,7 +170,7 @@ int main(int argc, char *argv[]) {
} }
} }
taosInitLog("client.log", 100000, 10); taosInitLog("client.log", 10);
void *pRpc = rpcOpen(&rpcInit); void *pRpc = rpcOpen(&rpcInit);
if (pRpc == NULL) { if (pRpc == NULL) {
......
...@@ -70,7 +70,7 @@ typedef struct { ...@@ -70,7 +70,7 @@ typedef struct {
int8_t tscEmbeddedInUtil = 0; int8_t tscEmbeddedInUtil = 0;
int32_t tsLogKeepDays = 0; int32_t tsLogKeepDays = 0;
int8_t tsAsyncLog = 1; bool tsAsyncLog = true;
float tsTotalLogDirGB = 0; float tsTotalLogDirGB = 0;
float tsAvailLogDirGB = 0; float tsAvailLogDirGB = 0;
float tsMinimalLogDirGB = 1.0f; float tsMinimalLogDirGB = 1.0f;
...@@ -79,20 +79,19 @@ int32_t writeInterval = DEFAULT_LOG_INTERVAL; ...@@ -79,20 +79,19 @@ int32_t writeInterval = DEFAULT_LOG_INTERVAL;
// log // log
int32_t tsNumOfLogLines = 10000000; int32_t tsNumOfLogLines = 10000000;
int32_t mDebugFlag = 131;
int32_t dDebugFlag = 135; int32_t dDebugFlag = 135;
int32_t vDebugFlag = 135; int32_t vDebugFlag = 135;
int32_t mDebugFlag = 131;
int32_t cDebugFlag = 131; int32_t cDebugFlag = 131;
int32_t jniDebugFlag = 131; int32_t jniDebugFlag = 131;
int32_t qDebugFlag = 131; int32_t tmrDebugFlag = 131;
int32_t rpcDebugFlag = 131;
int32_t uDebugFlag = 131; int32_t uDebugFlag = 131;
int32_t debugFlag = 0; int32_t rpcDebugFlag = 131;
int32_t sDebugFlag = 135; int32_t qDebugFlag = 131;
int32_t wDebugFlag = 135; int32_t wDebugFlag = 135;
int32_t sDebugFlag = 135;
int32_t tsdbDebugFlag = 131; int32_t tsdbDebugFlag = 131;
int32_t tqDebugFlag = 135; int32_t tqDebugFlag = 135;
int32_t cqDebugFlag = 131;
int32_t fsDebugFlag = 135; int32_t fsDebugFlag = 135;
int64_t dbgEmptyW = 0; int64_t dbgEmptyW = 0;
...@@ -120,10 +119,13 @@ static int32_t taosStartLog() { ...@@ -120,10 +119,13 @@ static int32_t taosStartLog() {
return 0; return 0;
} }
int32_t taosInitLog(char *logName, int numOfLogLines, int maxFiles) { int32_t taosInitLog(const char *logName, int maxFiles) {
char fullName[PATH_MAX] = {0};
snprintf(fullName, PATH_MAX, "%s" TD_DIRSEP "%s", tsLogDir, logName);
tsLogObj.logHandle = taosLogBuffNew(TSDB_DEFAULT_LOG_BUF_SIZE); tsLogObj.logHandle = taosLogBuffNew(TSDB_DEFAULT_LOG_BUF_SIZE);
if (tsLogObj.logHandle == NULL) return -1; if (tsLogObj.logHandle == NULL) return -1;
if (taosOpenLogFile(logName, numOfLogLines, maxFiles) < 0) return -1; if (taosOpenLogFile(fullName, tsNumOfLogLines, maxFiles) < 0) return -1;
if (taosStartLog() < 0) return -1; if (taosStartLog() < 0) return -1;
return 0; return 0;
} }
...@@ -774,11 +776,22 @@ void taosPrintOsInfo() { ...@@ -774,11 +776,22 @@ void taosPrintOsInfo() {
uInfo(" os machine: %s", info.machine); uInfo(" os machine: %s", info.machine);
} }
void taosSetDebugFlag(int32_t flag) { void taosSetAllDebugFlag(int32_t flag) {
if (!(debugFlag & DEBUG_TRACE || debugFlag & DEBUG_DEBUG || debugFlag & DEBUG_DUMP)) return; if (!(flag & DEBUG_TRACE || flag & DEBUG_DEBUG || flag & DEBUG_DUMP)) return;
debugFlag = flag;
mDebugFlag = flag;
dDebugFlag = flag; dDebugFlag = flag;
vDebugFlag = flag;
mDebugFlag = flag;
cDebugFlag = flag; cDebugFlag = flag;
jniDebugFlag = flag;
uDebugFlag = flag;
rpcDebugFlag = flag;
qDebugFlag = flag;
wDebugFlag = flag;
sDebugFlag = flag;
tsdbDebugFlag = flag;
tqDebugFlag = flag;
fsDebugFlag = flag;
uInfo("all debug flag are set to %d", flag);
} }
\ No newline at end of file
...@@ -81,7 +81,6 @@ typedef struct time_wheel_t { ...@@ -81,7 +81,6 @@ typedef struct time_wheel_t {
tmr_obj_t** slots; tmr_obj_t** slots;
} time_wheel_t; } time_wheel_t;
int32_t tmrDebugFlag = 131;
uint32_t tsMaxTmrCtrl = 512; uint32_t tsMaxTmrCtrl = 512;
static pthread_once_t tmrModuleInit = PTHREAD_ONCE_INIT; static pthread_once_t tmrModuleInit = PTHREAD_ONCE_INIT;
......
...@@ -158,7 +158,7 @@ int main(int argc, char *argv[]) { ...@@ -158,7 +158,7 @@ int main(int argc, char *argv[]) {
} }
} }
taosInitLog("tref.log", 5000000, 10); taosInitLog("tref.log", 10);
SRefSpace *pSpaceList = (SRefSpace *) calloc(sizeof(SRefSpace), threads); SRefSpace *pSpaceList = (SRefSpace *) calloc(sizeof(SRefSpace), threads);
pthread_t *pThreadList = (pthread_t *) calloc(sizeof(pthread_t), threads); pthread_t *pThreadList = (pthread_t *) calloc(sizeof(pthread_t), threads);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册