|
|
@@ -104,6 +104,94 @@ static inline ErrorCodeEnum ReadConfigFromCenterSettings(
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+static inline void InitializeOtherLogSwitch(CEntityBase* pEntity, const CSimpleStringA& strModuleName)
|
|
|
+{
|
|
|
+ LOG_FUNCTION();
|
|
|
+ if (pEntity == NULL || strModuleName.IsNullOrEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ struct OtherLogConfig
|
|
|
+ {
|
|
|
+ OtherLogConfig() :strLevel("OFF"), strType("FILE"), strDllName(""), strLogPath("") {}
|
|
|
+ OtherLogConfig(const CSimpleStringA& strModuleName) :strLevel("OFF"), strType("FILE"), strDllName(strModuleName), strLogPath("") {}
|
|
|
+
|
|
|
+ CSimpleStringA strLevel;
|
|
|
+ CSimpleStringA strType;
|
|
|
+ CSimpleStringA strDllName;
|
|
|
+ CSimpleStringA strLogPath;
|
|
|
+
|
|
|
+ void Settle()
|
|
|
+ {
|
|
|
+ toolkit_setenv("VENDOR_RECODE_LEVEL", strLevel);
|
|
|
+ toolkit_setenv("VENDOR_RECODE_TYPE", strType);
|
|
|
+ toolkit_setenv("VENDOR_DLL_NAME", strDllName);
|
|
|
+ toolkit_setenv("VENDOR_LOG_PATH", strLogPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ } stLogConfig(strModuleName);
|
|
|
+
|
|
|
+ CSmartPointer<IConfigInfo> centerConfig;
|
|
|
+ pEntity->GetFunction()->OpenConfig(Config_CenterSetting, centerConfig);
|
|
|
+
|
|
|
+ int nSaveFileOrNot(0);
|
|
|
+
|
|
|
+ centerConfig->ReadConfigValueInt("Common", "SaveFile", nSaveFileOrNot);
|
|
|
+ stLogConfig.strType = "UPLOAD";
|
|
|
+ if ((nSaveFileOrNot & 1) == 1) {
|
|
|
+ if (!stLogConfig.strType.IsNullOrEmpty()) stLogConfig.strType += "|";
|
|
|
+ stLogConfig.strType += "FILE";
|
|
|
+ }
|
|
|
+
|
|
|
+ int nUploadLogLevel(1); /*INFO*/
|
|
|
+
|
|
|
+ CSimpleStringA strUploadLogLevelEntity(true);
|
|
|
+ centerConfig->ReadConfigValue(strModuleName.GetData(), "UpLoadLogLevel", strUploadLogLevelEntity);
|
|
|
+ if (strUploadLogLevelEntity.IsNullOrEmpty()) {
|
|
|
+ CSimpleStringA strUploadLogLevelComm(true);
|
|
|
+ centerConfig->ReadConfigValue("Common", "UpLoadLogLevel", strUploadLogLevelComm);
|
|
|
+ strUploadLogLevelEntity = strUploadLogLevelComm;
|
|
|
+ }
|
|
|
+ bool isValidDigit = !strUploadLogLevelEntity.IsNullOrEmpty();
|
|
|
+ for (int i = 0; i < strUploadLogLevelEntity.GetLength(); ++i) {
|
|
|
+ if (!(strUploadLogLevelEntity[i] >= '0' && strUploadLogLevelEntity[i] <= '9')) {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("invalid param: %s", strUploadLogLevelEntity.GetData());
|
|
|
+ isValidDigit = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isValidDigit) {
|
|
|
+ nUploadLogLevel = atoi(strUploadLogLevelEntity.GetData());
|
|
|
+ }
|
|
|
+ switch (nUploadLogLevel)
|
|
|
+ {
|
|
|
+ case 0: /*LOG_LEVEL_DEBUG*/
|
|
|
+ stLogConfig.strLevel = "ALL";
|
|
|
+ break;
|
|
|
+ case 1: /*LOG_LEVEL_INFO*/
|
|
|
+ stLogConfig.strLevel = "INFO";
|
|
|
+ break;
|
|
|
+ case 2: /*LOG_LEVEL_WARN*/
|
|
|
+ stLogConfig.strLevel = "WARN";
|
|
|
+ break;
|
|
|
+ case 3: /*LOG_LEVEL_ERROR*/
|
|
|
+ stLogConfig.strLevel = "ERROR";
|
|
|
+ break;
|
|
|
+ case 4: /*LOG_LEVEL_FATAL*/
|
|
|
+ stLogConfig.strLevel = "FATAL";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ stLogConfig.strLevel = "OFF";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ pEntity->GetFunction()->GetPath("Dbg", stLogConfig.strLogPath);
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("DbgPath: %s", stLogConfig.strLogPath.GetData());
|
|
|
+ stLogConfig.Settle();
|
|
|
+
|
|
|
+ LogEvent(Severity_Low, 0, CSimpleStringA::Format("{\"RecordLevel\":\"%s\", \"RecordType\":\"%s\}", stLogConfig.strLevel.GetData(), stLogConfig.strType.GetData()));
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
} //namespace Settings
|
|
|
} //namespace Comm
|