diff --git a/include/os/osEnv.h b/include/os/osEnv.h index a7fd86776c..fec3b1abc4 100644 --- a/include/os/osEnv.h +++ b/include/os/osEnv.h @@ -22,8 +22,6 @@ extern "C" { extern char tsOsName[]; extern char tsDataDir[]; -extern char tsLogDir[]; -extern char tsScriptDir[]; extern char configDir[]; #ifdef __cplusplus diff --git a/include/util/tlog.h b/include/util/tlog.h index 7499eaa7b4..cdcac84ab7 100644 --- a/include/util/tlog.h +++ b/include/util/tlog.h @@ -22,7 +22,8 @@ extern "C" { #endif -// log +extern char tsLogDir[]; +extern bool tsLogInited; extern bool tsAsyncLog; extern int32_t tsNumOfLogLines; extern int32_t tsLogKeepDays; @@ -41,20 +42,21 @@ extern int32_t tsdbDebugFlag; extern int32_t tqDebugFlag; extern int32_t fsDebugFlag; -#define DEBUG_FATAL 1U -#define DEBUG_ERROR DEBUG_FATAL -#define DEBUG_WARN 2U -#define DEBUG_INFO DEBUG_WARN -#define DEBUG_DEBUG 4U -#define DEBUG_TRACE 8U -#define DEBUG_DUMP 16U - +#define DEBUG_FATAL 1U +#define DEBUG_ERROR DEBUG_FATAL +#define DEBUG_WARN 2U +#define DEBUG_INFO DEBUG_WARN +#define DEBUG_DEBUG 4U +#define DEBUG_TRACE 8U +#define DEBUG_DUMP 16U #define DEBUG_SCREEN 64U -#define DEBUG_FILE 128U +#define DEBUG_FILE 128U int32_t taosInitLog(const char *logName, int32_t maxFiles); void taosCloseLog(); void taosResetLog(); +void taosSetAllDebugFlag(int32_t flag); +void taosDumpData(unsigned char *msg, int32_t len); void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...) #ifdef __GNUC__ @@ -68,11 +70,6 @@ void taosPrintLongString(const char *flags, int32_t dflag, const char *format, . #endif ; -void taosDumpData(unsigned char *msg, int32_t len); - - -void taosSetAllDebugFlag(int32_t flag); - #ifdef __cplusplus } #endif diff --git a/source/client/src/clientCfg.c b/source/client/src/clientCfg.c index 352495178b..ca671ab150 100644 --- a/source/client/src/clientCfg.c +++ b/source/client/src/clientCfg.c @@ -83,6 +83,8 @@ static int32_t tscSetLogCfg(SConfig *pCfg) { } int32_t tscInitLog(const char *cfgDir, const char *envFile, const char *apolloUrl) { + if (tsLogInited) return 0; + SConfig *pCfg = cfgInit(); if (pCfg == NULL) return -1; @@ -111,6 +113,7 @@ int32_t tscInitLog(const char *cfgDir, const char *envFile, const char *apolloUr return -1; } + cfgDumpCfg(pCfg); cfgCleanup(pCfg); return 0; } @@ -151,7 +154,7 @@ static int32_t tscAddCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "numOfCores", 1, 1, 100000) != 0) return -1; if (cfgAddInt32(pCfg, "numOfCommitThreads", 4, 1, 1000) != 0) return -1; // if (cfgAddBool(pCfg, "telemetryReporting", 0) != 0) return -1; - // if (cfgAddBool(pCfg, "enableCoreFile", 0) != 0) return -1; + if (cfgAddBool(pCfg, "enableCoreFile", 0) != 0) return -1; // if (cfgAddInt32(pCfg, "supportVnodes", 256, 0, 65536) != 0) return -1; if (cfgAddInt32(pCfg, "statusInterval", 1, 1, 30) != 0) return -1; if (cfgAddFloat(pCfg, "numOfThreadsPerCore", 1, 0, 10) != 0) return -1; @@ -174,12 +177,6 @@ SConfig *tscInitCfgImp(const char *cfgDir, const char *envFile, const char *apol SConfig *pCfg = cfgInit(); if (pCfg == NULL) return NULL; - if (tscAddLogCfg(pCfg) != 0) { - uError("failed to add log cfg since %s", terrstr()); - cfgCleanup(pCfg); - return NULL; - } - if (tscAddCfg(pCfg) != 0) { uError("failed to init tsc cfg since %s", terrstr()); cfgCleanup(pCfg); diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index fc25dac0df..9bd9386244 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -280,15 +280,6 @@ static void doInitGlobalConfig(void) { #if 0 SGlobalCfg cfg = {0}; - cfg.option = "scriptDir"; - cfg.ptr = tsScriptDir; - cfg.valType = TAOS_CFG_VTYPE_DIRECTORY; - cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT; - cfg.minValue = 0; - cfg.maxValue = 0; - cfg.ptrLength = TSDB_FILENAME_LEN; - cfg.unitType = TAOS_CFG_UTYPE_NONE; - taosAddConfigOption(cfg); cfg.option = "dataDir"; cfg.ptr = tsDataDir; diff --git a/source/dnode/mgmt/daemon/src/dmnCfg.c b/source/dnode/mgmt/daemon/src/dmnCfg.c index 1f68df6fe4..d3cdc30870 100644 --- a/source/dnode/mgmt/daemon/src/dmnCfg.c +++ b/source/dnode/mgmt/daemon/src/dmnCfg.c @@ -202,7 +202,7 @@ SDnodeObjCfg dmnGetObjCfg(SConfig *pCfg) { tstrncpy(objCfg.firstEp, cfgGetItem(pCfg, "firstEp")->str, sizeof(objCfg.firstEp)); tstrncpy(objCfg.secondEp, cfgGetItem(pCfg, "secondEp")->str, sizeof(objCfg.firstEp)); objCfg.serverPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32; - tstrncpy(objCfg.localFqdn, cfgGetItem(pCfg, "fqdn")->str, sizeof(objCfg.localFqdn, cfgGetItem)); + tstrncpy(objCfg.localFqdn, cfgGetItem(pCfg, "fqdn")->str, sizeof(objCfg.localFqdn)); snprintf(objCfg.localEp, sizeof(objCfg.localEp), "%s:%u", objCfg.localFqdn, objCfg.serverPort); return objCfg; } \ No newline at end of file diff --git a/source/libs/config/src/config.c b/source/libs/config/src/config.c index 25b65a0d1b..17a652d2b5 100644 --- a/source/libs/config/src/config.c +++ b/source/libs/config/src/config.c @@ -15,11 +15,14 @@ #define _DEFAULT_SOURCE #include "cfgInt.h" -#include "tmsg.h" #include "tep.h" #include "tlocale.h" +#include "tmsg.h" #include "ttimezone.h" +#define CFG_NAME_PRINT_LEN 22 +#define CFG_SRC_PRINT_LEN 12 + SConfig *cfgInit() { SConfig *pCfg = calloc(1, sizeof(SConfig)); if (pCfg == NULL) { @@ -505,56 +508,37 @@ const char *cfgDtypeStr(ECfgDataType type) { } } -void cfgPrintCfg(SConfig *pCfg) { - uInfo("taos global config"); - uInfo("=================================="); - - SConfigItem *pItem = cfgIterate(pCfg, NULL); - while (pItem != NULL) { - switch (pItem->dtype) { - case CFG_DTYPE_BOOL: - uInfo("cfg:%s, value:%u src:%s", pItem->name, pItem->bval, cfgStypeStr(pItem->stype)); - break; - case CFG_DTYPE_INT32: - uInfo("cfg:%s, value:%d src:%s", pItem->name, pItem->i32, cfgStypeStr(pItem->stype)); - break; - case CFG_DTYPE_INT64: - uInfo("cfg:%s, value:%" PRId64 " src:%s", pItem->name, pItem->i64, cfgStypeStr(pItem->stype)); - break; - case CFG_DTYPE_FLOAT: - uInfo("cfg:%s, value:%f src:%s", pItem->name, pItem->fval, cfgStypeStr(pItem->stype)); - break; - case CFG_DTYPE_STRING: - case CFG_DTYPE_IPSTR: - case CFG_DTYPE_DIR: - case CFG_DTYPE_LOCALE: - case CFG_DTYPE_CHARSET: - case CFG_DTYPE_TIMEZONE: - uInfo("cfg:%s, value:%s src:%s", pItem->name, pItem->str, cfgStypeStr(pItem->stype)); - break; - } - pItem = cfgIterate(pCfg, pItem); - } -} - void cfgDumpCfg(SConfig *pCfg) { - uInfo("global config"); - uInfo("=================================="); + uInfo(" global config"); + uInfo("================================================================="); + + char src[CFG_SRC_PRINT_LEN + 1] = {0}; + char name[CFG_NAME_PRINT_LEN + 1] = {0}; SConfigItem *pItem = cfgIterate(pCfg, NULL); while (pItem != NULL) { + tstrncpy(src, cfgStypeStr(pItem->stype), CFG_SRC_PRINT_LEN); + for (int32_t i = 0; i < CFG_SRC_PRINT_LEN; ++i) { + if (src[i] == 0) src[i] = ' '; + } + + tstrncpy(name, pItem->name, CFG_NAME_PRINT_LEN); + for (int32_t i = 0; i < CFG_NAME_PRINT_LEN; ++i) { + if (name[i] == 0) name[i] = ' '; + } + switch (pItem->dtype) { case CFG_DTYPE_BOOL: - uInfo("cfg:%s, value:%u src:%s", pItem->name, pItem->bval, cfgStypeStr(pItem->stype)); + uInfo("%s %s %u", src, name, pItem->bval); break; case CFG_DTYPE_INT32: - uInfo("cfg:%s, value:%d src:%s", pItem->name, pItem->i32, cfgStypeStr(pItem->stype)); + uInfo("%s %s %d", src, name, pItem->i32); break; case CFG_DTYPE_INT64: - uInfo("cfg:%s, value:%" PRId64 " src:%s", pItem->name, pItem->i64, cfgStypeStr(pItem->stype)); + uInfo("%s %s %" PRId64, src, name, pItem->i64); break; case CFG_DTYPE_FLOAT: - uInfo("cfg:%s, value:%f src:%s", pItem->name, pItem->fval, cfgStypeStr(pItem->stype)); + uInfo("%s %s %f", src, name, pItem->fval); break; case CFG_DTYPE_STRING: case CFG_DTYPE_IPSTR: @@ -562,13 +546,13 @@ void cfgDumpCfg(SConfig *pCfg) { case CFG_DTYPE_LOCALE: case CFG_DTYPE_CHARSET: case CFG_DTYPE_TIMEZONE: - uInfo("cfg:%s, value:%s src:%s", pItem->name, pItem->str, cfgStypeStr(pItem->stype)); + uInfo("%s %s %s", src, name, pItem->str); break; } pItem = cfgIterate(pCfg, pItem); } - uInfo("=================================="); + uInfo("================================================================="); } #if 0 // int32_t cfgCheck(SConfig *pCfg) { diff --git a/source/os/src/osEnv.c b/source/os/src/osEnv.c index 7bc5e0a7fc..38e564fa9d 100644 --- a/source/os/src/osEnv.c +++ b/source/os/src/osEnv.c @@ -23,7 +23,6 @@ char tsOsName[10] = "Windows"; char configDir[PATH_MAX] = "C:/TDengine/cfg"; char tsDataDir[PATH_MAX] = "C:/TDengine/data"; char tsLogDir[PATH_MAX] = "C:/TDengine/log"; -char tsScriptDir[PATH_MAX] = "C:/TDengine/script"; char tsTempDir[PATH_MAX] = "C:\\Windows\\Temp"; extern taosWinSocketInit(); @@ -47,7 +46,6 @@ char tsOsName[10] = "Darwin"; char configDir[PATH_MAX] = "/usr/local/etc/taos"; char tsDataDir[PATH_MAX] = "/usr/local/var/lib/taos"; char tsLogDir[PATH_MAX] = "/usr/local/var/log/taos"; -char tsScriptDir[PATH_MAX] = "/usr/local/etc/taos"; char tsTempDir[PATH_MAX] = "/tmp/taosd"; void osInit() {} @@ -58,7 +56,6 @@ char tsOsName[10] = "Linux"; char configDir[PATH_MAX] = "/etc/taos"; char tsDataDir[PATH_MAX] = "/var/lib/taos"; char tsLogDir[PATH_MAX] = "/var/log/taos"; -char tsScriptDir[PATH_MAX] = "/etc/taos"; char tsTempDir[PATH_MAX] = "/tmp/"; void osInit() {}