loggingagent.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2014 HPCC Systems.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #include "httpclient.hpp"
  14. #include "ws_loggingservice_esp.ipp"
  15. #include "LoggingErrors.hpp"
  16. #include "loggingcommon.hpp"
  17. #include "loggingagentbase.hpp"
  18. #include "loggingagent.hpp"
  19. static const int DefaultMaxTriesGTS = -1;
  20. static const char* const PropESPServer = "ESPServer";
  21. static const char* const PropServerUrl = "@url";
  22. static const char* const PropServerUserID = "@user";
  23. static const char* const PropServerPassword = "@password";
  24. static const char* const PropServerWaitingSeconds = "MaxServerWaitingSeconds";
  25. static const char* const MaxTriesGTS = "MaxTriesGTS";
  26. static const char* const appESPServerLoggingAgent = "ESPServerLoggingAgent";
  27. bool CESPServerLoggingAgent::init(const char * name, const char * type, IPropertyTree * cfg, const char * process)
  28. {
  29. if (!cfg)
  30. return false;
  31. IPropertyTree* espServer = cfg->queryBranch(PropESPServer);
  32. if(!espServer)
  33. throw MakeStringException(-1,"Unable to find ESPServer settings for log agent %s:%s", name, type);
  34. const char* url = espServer->queryProp(PropServerUrl);
  35. if (url && *url)
  36. serverUrl.set(url);
  37. const char* userID = espServer->queryProp(PropServerUserID);
  38. const char* password = espServer->queryProp(PropServerPassword);
  39. if (userID && *userID && password && *password)
  40. {
  41. serverUserID.set(userID);
  42. decrypt(serverPassword, password);
  43. }
  44. maxServerWaitingSeconds = cfg->getPropInt(PropServerWaitingSeconds);
  45. maxGTSRetries = cfg->getPropInt(MaxTriesGTS, DefaultMaxTriesGTS);
  46. BoolHash uniqueGroupNames;
  47. StringBuffer sourceName, groupName, dbName, localTransactionSeed;
  48. Owned<IPropertyTreeIterator> iter = cfg->getElements("LogSourceMap/LogSource");
  49. ForEach(*iter)
  50. {
  51. ensureInputString(iter->query().queryProp("@name"), false, sourceName, -1, "LogSource @name required");
  52. ensureInputString(iter->query().queryProp("@maptologgroup"), true, groupName, -1, "LogSource @maptologgroup required");
  53. ensureInputString(iter->query().queryProp("@maptodb"), true, dbName, -1, "LogSource @maptodb required");
  54. Owned<CLogSource> logSource = new CLogSource(sourceName.str(), groupName.str(), dbName.str());
  55. logSources.setValue(sourceName.str(), logSource);
  56. bool* found = uniqueGroupNames.getValue(groupName.str());
  57. if (!found || !*found)
  58. {
  59. uniqueGroupNames.setValue(groupName.str(), true);
  60. StringBuffer transactionSeed, statusMessage;
  61. getTransactionSeed(groupName.str(), transactionSeed, statusMessage);
  62. if (transactionSeed.length() > 0)
  63. {
  64. Owned<CTransIDBuilder> entry = new CTransIDBuilder(transactionSeed.str(), false);
  65. transIDMap.setValue(groupName.str(), entry);
  66. if (iter->query().getPropBool("@default", false))
  67. defaultGroup.set(groupName.str());
  68. }
  69. else
  70. PROGLOG("Failed to get TransactionSeed for <%s>", groupName.str());
  71. }
  72. }
  73. createLocalTransactionSeed(localTransactionSeed);
  74. Owned<CTransIDBuilder> localTransactionEntry = new CTransIDBuilder(localTransactionSeed.str(), true);
  75. transIDMap.setValue(appESPServerLoggingAgent, localTransactionEntry);
  76. readAllLogFilters(cfg);
  77. return true;
  78. }
  79. void CESPServerLoggingAgent::readAllLogFilters(IPropertyTree* cfg)
  80. {
  81. bool groupFilterRead = false;
  82. VStringBuffer xpath("Filters/Filter[@type='%s']", espLogContentGroupNames[ESPLCGBackEndResp]);
  83. IPropertyTree* filter = cfg->queryBranch(xpath.str());
  84. if (filter && filter->hasProp("@value"))
  85. {
  86. logBackEndResp = filter->getPropBool("@value");
  87. groupFilterRead = true;
  88. }
  89. for (unsigned i = 0; i < ESPLCGBackEndResp; i++)
  90. {
  91. if (readLogFilters(cfg, i))
  92. groupFilterRead = true;
  93. }
  94. if (!groupFilterRead)
  95. {
  96. groupFilters.clear();
  97. readLogFilters(cfg, ESPLCGAll);
  98. }
  99. }
  100. bool CESPServerLoggingAgent::readLogFilters(IPropertyTree* cfg, unsigned groupID)
  101. {
  102. Owned<CESPLogContentGroupFilters> espLogContentGroupFilters = new CESPLogContentGroupFilters((ESPLogContentGroup) groupID);
  103. StringBuffer xpath;
  104. if (groupID != ESPLCGAll)
  105. xpath.appendf("Filters/Filter[@type='%s']", espLogContentGroupNames[groupID]);
  106. else
  107. xpath.append("Filters/Filter");
  108. Owned<IPropertyTreeIterator> filters = cfg->getElements(xpath.str());
  109. ForEach(*filters)
  110. {
  111. IPropertyTree &filter = filters->query();
  112. StringBuffer value = filter.queryProp("@value");
  113. if (!value.length())
  114. continue;
  115. //clean "//"
  116. unsigned idx = value.length()-1;
  117. while (idx)
  118. {
  119. if ((value.charAt(idx-1) == '/') && (value.charAt(idx) == '/'))
  120. value.remove(idx, 1);
  121. idx--;
  122. }
  123. //clean "/*" at the end
  124. while ((value.length() > 1) && (value.charAt(value.length()-2) == '/') && (value.charAt(value.length()-1) == '*'))
  125. value.setLength(value.length() - 2);
  126. if (value.length() && !streq(value.str(), "*") && !streq(value.str(), "/") && !streq(value.str(), "*/"))
  127. {
  128. espLogContentGroupFilters->addFilter(value.str());
  129. }
  130. else
  131. {
  132. espLogContentGroupFilters->clearFilters();
  133. break;
  134. }
  135. }
  136. bool hasFilter = espLogContentGroupFilters->getFilterCount() > 0;
  137. if (hasFilter)
  138. groupFilters.append(*espLogContentGroupFilters.getClear());
  139. return hasFilter;
  140. }
  141. void CESPServerLoggingAgent::createLocalTransactionSeed(StringBuffer& transactionSeed)
  142. {
  143. unsigned ip = queryHostIP().iphash();
  144. unsigned mstick6char = ((unsigned)usTick() & 0xFFFFFF);
  145. unsigned processId2char = ((unsigned)GetCurrentProcessId()) & 0xF;
  146. unsigned threadId1char = ((unsigned) (memsize_t) GetCurrentThreadId()) & 0xF;
  147. transactionSeed.setf("%02X%06X%X%X", ip, mstick6char, processId2char, threadId1char);
  148. }
  149. bool CESPServerLoggingAgent::getTransactionSeed(IEspGetTransactionSeedRequest& req, IEspGetTransactionSeedResponse& resp)
  150. {
  151. StringBuffer statusMessage, transactionSeed;
  152. int statusCode = getTransactionSeed(req.getApplication(), transactionSeed, statusMessage);
  153. resp.setStatusCode(statusCode);
  154. resp.setSeedId(transactionSeed.str());
  155. if (statusMessage.length())
  156. resp.setStatusMessage(statusMessage.str());
  157. return (statusCode != -2);
  158. }
  159. int CESPServerLoggingAgent::getTransactionSeed(const char* appName, StringBuffer& transactionSeed, StringBuffer& statusMessage)
  160. {
  161. StringBuffer soapreq(
  162. "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
  163. "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\""
  164. " xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\">"
  165. " <soap:Body>");
  166. if (!appName || !*appName)
  167. soapreq.append("<GetTransactionSeedRequest/>");
  168. else
  169. soapreq.append("<GetTransactionSeedRequest><Application>").append(appName).append("</Application></GetTransactionSeedRequest>");
  170. soapreq.append("</soap:Body></soap:Envelope>");
  171. unsigned retry = 1;
  172. int statusCode = 0;
  173. while (1)
  174. {
  175. try
  176. {
  177. if (!getTransactionSeed(soapreq, statusCode, statusMessage, transactionSeed))
  178. throw MakeStringException(EspLoggingErrors::GetTransactionSeedFailed,"Failed to get TransactionSeed");
  179. break;
  180. }
  181. catch (IException* e)
  182. {
  183. StringBuffer errorStr;
  184. statusMessage.set("Failed to get TransactionSeed: error code ").append(e->errorCode()).append(", error message ").append(e->errorMessage(errorStr));
  185. ERRLOG("%s -- try %d", statusMessage.str(), retry);
  186. e->Release();
  187. if (retry >= maxGTSRetries)
  188. {
  189. statusCode = -2;
  190. break;
  191. }
  192. Sleep(retry*3000);
  193. retry++;
  194. }
  195. }
  196. return statusCode;
  197. }
  198. bool CESPServerLoggingAgent::getTransactionSeed(StringBuffer& soapreq, int& statusCode, StringBuffer& statusMessage, StringBuffer& seedID)
  199. {
  200. StringBuffer status, response;
  201. if (!sendHTTPRequest(soapreq, response, status) || !response.length() || !status.length())
  202. throw MakeStringException(EspLoggingErrors::GetTransactionSeedFailed, "Failed to send Transaction Seed request to %s", serverUrl.str());
  203. if (!strieq(status, "200 OK"))
  204. throw MakeStringException(EspLoggingErrors::GetTransactionSeedFailed, "%s", status.str());
  205. Owned<IPropertyTree> pTree = createPTreeFromXMLString(response.str());
  206. if (!pTree)
  207. throw MakeStringException(EspLoggingErrors::GetTransactionSeedFailed, "Failed to read response from %s", serverUrl.str());
  208. statusCode = pTree->getPropInt("soap:Body/GetTransactionSeedResponse/StatusCode");
  209. statusMessage.set(pTree->queryProp("soap:Body/GetTransactionSeedResponse/StatusMessage"));
  210. seedID.set(pTree->queryProp("soap:Body/GetTransactionSeedResponse/SeedId"));
  211. if (statusCode || !seedID.length())
  212. throw MakeStringException(EspLoggingErrors::GetTransactionSeedFailed, "Failed to get Transaction Seed from %s", serverUrl.str());
  213. return true;
  214. }
  215. void CESPServerLoggingAgent::getTransactionID(StringAttrMapping* transFields, StringBuffer& transactionID)
  216. {
  217. CTransIDBuilder* transIDBuilder = NULL;
  218. StringAttr* source = transFields->getValue(sTransactionMethod);
  219. if (source)
  220. {
  221. CLogSource* logSource = logSources.getValue(source->get());
  222. if (logSource)
  223. transIDBuilder = transIDMap.getValue(logSource->getGroupName());
  224. }
  225. if (!transIDBuilder && (defaultGroup.length() != 0))
  226. transIDBuilder = transIDMap.getValue(defaultGroup.str());
  227. if (!transIDBuilder)
  228. transIDBuilder = transIDMap.getValue(appESPServerLoggingAgent);
  229. if (!transIDBuilder) //This should not happen.
  230. throw MakeStringException(EspLoggingErrors::GetTransactionSeedFailed, "Failed to getTransactionID");
  231. transIDBuilder->getTransID(transFields, transactionID);
  232. return;
  233. }
  234. bool CESPServerLoggingAgent::updateLog(IEspUpdateLogRequestWrap& req, IEspUpdateLogResponse& resp)
  235. {
  236. try
  237. {
  238. StringBuffer soapreq(
  239. "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
  240. "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\""
  241. " xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\">"
  242. " <soap:Body>"
  243. );
  244. soapreq.append(req.getUpdateLogRequest());
  245. soapreq.append("</soap:Body></soap:Envelope>");
  246. StringBuffer status, respStr;
  247. if (sendHTTPRequest(soapreq, respStr, status) && status.length() && strieq(status, "200 OK"))
  248. resp.setStatusCode(0);
  249. else if (status.length() && !strieq(status, "200 OK"))
  250. throw MakeStringException(EspLoggingErrors::UpdateLogFailed, "%s", status.str());
  251. else if (respStr.length())
  252. throw MakeStringException(EspLoggingErrors::UpdateLogFailed, "%s", respStr.str());
  253. else
  254. throw MakeStringException(EspLoggingErrors::UpdateLogFailed, "Failed to send update log request to %s", serverUrl.str());
  255. }
  256. catch (IException* e)
  257. {//retry will be in update log queue.
  258. StringBuffer errorStr, errorMessage;
  259. errorMessage.append("Failed to update log: error code ").append(e->errorCode()).append(", error message ").append(e->errorMessage(errorStr));
  260. ERRLOG("%s", errorMessage.str());
  261. resp.setStatusCode(-1);
  262. resp.setStatusMessage(errorMessage.str());
  263. e->Release();
  264. }
  265. return true;
  266. }
  267. void CESPServerLoggingAgent::addLogContentBranch(StringArray& branchNames, IPropertyTree* contentToLogBranch, IPropertyTree* updateLogRequestTree)
  268. {
  269. IPropertyTree* pTree = updateLogRequestTree;
  270. unsigned numOfBranchNames = branchNames.length();
  271. if (numOfBranchNames > 0)
  272. {
  273. unsigned i = 0;
  274. while (i < numOfBranchNames)
  275. {
  276. const char* branchName = branchNames.item(i);
  277. if (branchName && *branchName)
  278. pTree = ensurePTree(pTree, branchName);
  279. i++;
  280. }
  281. }
  282. pTree->addPropTree(contentToLogBranch->queryName(), LINK(contentToLogBranch));
  283. }
  284. void CESPServerLoggingAgent::filterAndAddLogContentBranch(StringArray& branchNamesInFilter, unsigned idx,
  285. StringArray& branchNamesInLogContent, IPropertyTree* originalLogContentBranch, IPropertyTree* updateLogRequestTree, bool& logContentEmpty)
  286. {
  287. Owned<IPropertyTreeIterator> contentItr = originalLogContentBranch->getElements(branchNamesInFilter.item(idx));
  288. ForEach(*contentItr)
  289. {
  290. IPropertyTree& contentToLogBranch = contentItr->query();
  291. if (idx == branchNamesInFilter.length() - 1)
  292. {
  293. addLogContentBranch(branchNamesInLogContent, &contentToLogBranch, updateLogRequestTree);
  294. logContentEmpty = false;
  295. }
  296. else
  297. {
  298. branchNamesInLogContent.append(contentToLogBranch.queryName());
  299. filterAndAddLogContentBranch(branchNamesInFilter, idx+1, branchNamesInLogContent, &contentToLogBranch,
  300. updateLogRequestTree, logContentEmpty);
  301. branchNamesInLogContent.remove(branchNamesInLogContent.length() - 1);
  302. }
  303. }
  304. }
  305. void CESPServerLoggingAgent::filterLogContentTree(StringArray& filters, IPropertyTree* originalContentTree, IPropertyTree* newLogContentTree, bool& logContentEmpty)
  306. {
  307. ForEachItemIn(i, filters)
  308. {
  309. const char* logContentFilter = filters.item(i);
  310. if(!logContentFilter || !*logContentFilter)
  311. continue;
  312. StringArray branchNamesInFilter, branchNamesInLogContent;
  313. branchNamesInFilter.appendListUniq(logContentFilter, "/");
  314. filterAndAddLogContentBranch(branchNamesInFilter, 0, branchNamesInLogContent, originalContentTree, newLogContentTree, logContentEmpty);
  315. }
  316. }
  317. void CESPServerLoggingAgent::filterLogContent(IEspUpdateLogRequestWrap* req)
  318. {
  319. const char* logContent = req->getUpdateLogRequest();
  320. Owned<IPropertyTree> updateLogRequestTree = createPTree("UpdateLogRequest");
  321. StringBuffer source;
  322. if (groupFilters.length() < 1)
  323. {//No filter
  324. if (logContent && *logContent)
  325. {
  326. Owned<IPropertyTree> pTree = createPTreeFromXMLString(logContent);
  327. source = pTree->queryProp("Source");
  328. updateLogRequestTree->addPropTree(pTree->queryName(), LINK(pTree));
  329. }
  330. else
  331. {
  332. Owned<IPropertyTree> espContext = req->getESPContext();
  333. Owned<IPropertyTree> userContext = req->getUserContext();
  334. Owned<IPropertyTree> userRequest = req->getUserRequest();
  335. const char* userResp = req->getUserResponse();
  336. const char* logDatasets = req->getLogDatasets();
  337. const char* backEndResp = req->getBackEndResponse();
  338. if (!espContext && !userContext && !userRequest && (!userResp || !*userResp) && (!backEndResp || !*backEndResp))
  339. throw MakeStringException(EspLoggingErrors::UpdateLogFailed, "Failed to read log content");
  340. source = userContext->queryProp("Source");
  341. StringBuffer espContextXML, userContextXML, userRequestXML;
  342. IPropertyTree* logContentTree = ensurePTree(updateLogRequestTree, "LogContent");
  343. if (espContext)
  344. {
  345. logContentTree->addPropTree(espContext->queryName(), LINK(espContext));
  346. }
  347. if (userContext)
  348. {
  349. IPropertyTree* pTree = ensurePTree(logContentTree, espLogContentGroupNames[ESPLCGUserContext]);
  350. pTree->addPropTree(userContext->queryName(), LINK(userContext));
  351. }
  352. if (userRequest)
  353. {
  354. IPropertyTree* pTree = ensurePTree(logContentTree, espLogContentGroupNames[ESPLCGUserReq]);
  355. pTree->addPropTree(userRequest->queryName(), LINK(userRequest));
  356. }
  357. if (userResp && *userResp)
  358. {
  359. IPropertyTree* pTree = ensurePTree(logContentTree, espLogContentGroupNames[ESPLCGUserResp]);
  360. Owned<IPropertyTree> userRespTree = createPTreeFromXMLString(userResp);
  361. pTree->addPropTree(userRespTree->queryName(), LINK(userRespTree));
  362. }
  363. if (logDatasets && *logDatasets)
  364. {
  365. IPropertyTree* pTree = ensurePTree(logContentTree, espLogContentGroupNames[ESPLCGLogDatasets]);
  366. Owned<IPropertyTree> logDatasetTree = createPTreeFromXMLString(logDatasets);
  367. pTree->addPropTree(logDatasetTree->queryName(), LINK(logDatasetTree));
  368. }
  369. if (backEndResp && *backEndResp)
  370. logContentTree->addProp(espLogContentGroupNames[ESPLCGBackEndResp], backEndResp);
  371. }
  372. }
  373. else
  374. {
  375. bool logContentEmpty = true;
  376. IPropertyTree* logContentTree = ensurePTree(updateLogRequestTree, "LogContent");
  377. if (logContent && *logContent)
  378. {
  379. Owned<IPropertyTree> originalContentTree = createPTreeFromXMLString(logContent);
  380. source = originalContentTree->queryProp("Source");
  381. filterLogContentTree(groupFilters.item(0).getFilters(), originalContentTree, logContentTree, logContentEmpty);
  382. }
  383. else
  384. {
  385. for (unsigned group = 0; group < ESPLCGBackEndResp; group++)
  386. {
  387. Owned<IPropertyTree> originalContentTree;
  388. if (group == ESPLCGESPContext)
  389. originalContentTree.setown(req->getESPContext());
  390. else if (group == ESPLCGUserContext)
  391. {
  392. originalContentTree.setown(req->getUserContext());
  393. source = originalContentTree->queryProp("Source");
  394. }
  395. else if (group == ESPLCGUserReq)
  396. originalContentTree.setown(req->getUserRequest());
  397. else if (group == ESPLCGLogDatasets)
  398. {
  399. const char* logDatasets = req->getLogDatasets();
  400. if (logDatasets && *logDatasets)
  401. originalContentTree.setown(createPTreeFromXMLString(logDatasets));
  402. }
  403. else //group = ESPLCGUserResp
  404. {
  405. const char* resp = req->getUserResponse();
  406. if (!resp || !*resp)
  407. continue;
  408. originalContentTree.setown(createPTreeFromXMLString(resp));
  409. }
  410. if (!originalContentTree)
  411. continue;
  412. IPropertyTree* newContentTree = ensurePTree(logContentTree, espLogContentGroupNames[group]);
  413. bool hasFilters = false;
  414. ForEachItemIn(i, groupFilters)
  415. {
  416. CESPLogContentGroupFilters& filtersGroup = groupFilters.item(i);
  417. if (filtersGroup.getGroup() == group)
  418. {
  419. if (group != ESPLCGESPContext)//For non ESPLCGESPContext, we want to keep the root of original tree.
  420. newContentTree = ensurePTree(newContentTree, originalContentTree->queryName());
  421. filterLogContentTree(filtersGroup.getFilters(), originalContentTree, newContentTree, logContentEmpty);
  422. hasFilters = true;
  423. break;
  424. }
  425. }
  426. if (!hasFilters)
  427. {
  428. newContentTree->addPropTree(originalContentTree->queryName(), LINK(originalContentTree));
  429. logContentEmpty = false;
  430. }
  431. }
  432. if (logBackEndResp)
  433. {
  434. const char* resp = req->getBackEndResponse();
  435. if (resp && *resp)
  436. {
  437. logContentTree->addProp(espLogContentGroupNames[ESPLCGBackEndResp], resp);
  438. logContentEmpty = false;
  439. }
  440. }
  441. }
  442. if (logContentEmpty)
  443. throw MakeStringException(EspLoggingErrors::UpdateLogFailed, "Failed to read log content");
  444. }
  445. if (!source.isEmpty())
  446. updateLogRequestTree->addProp("LogContent/Source", source.str());
  447. const char* option = req->getOption();
  448. if (option && *option)
  449. updateLogRequestTree->addProp("Option", option);
  450. StringBuffer updateLogRequestXML;
  451. toXML(updateLogRequestTree, updateLogRequestXML);
  452. ESPLOG(LogMax, "filtered content and option: <%s>", updateLogRequestXML.str());
  453. req->clearOriginalContent();
  454. req->setUpdateLogRequest(updateLogRequestXML.str());
  455. }
  456. bool CESPServerLoggingAgent::sendHTTPRequest(StringBuffer& req, StringBuffer &resp, StringBuffer &status)
  457. {
  458. Owned<IHttpClientContext> httpctx = getHttpClientContext();
  459. Owned <IHttpClient> httpclient = httpctx->createHttpClient(NULL, serverUrl.str());
  460. if (serverUserID.length() && serverPassword.length())
  461. {
  462. httpclient->setUserID(serverUserID.str());
  463. httpclient->setPassword(serverPassword.str());
  464. }
  465. httpclient->setTimeOut(maxServerWaitingSeconds);
  466. return !httpclient->sendRequest("POST", "text/xml", req, resp, status);
  467. }
  468. extern "C"
  469. {
  470. ESPSERVERLOGGINGAGENT_API IEspLogAgent* newLoggingAgent()
  471. {
  472. return new CESPServerLoggingAgent();
  473. }
  474. }