bool CWsLoggingServiceEx::onUpdateLog(IEspContext& context, IEspUpdateLogRequest& req, IEspUpdateLogResponse& resp) { try { if (!context.validateFeatureAccess(WSLOGGING_ACCESS, SecAccess_Write, false)) throw MakeStringException(EspLoggingErrors::WSLoggingAccessDenied, "Failed to update log. Permission denied."); for (unsigned int x = 0; x < loggingAgentThreads.size(); x++) { IUpdateLogThread* loggingThread = loggingAgentThreads[x]; if (!loggingThread->hasService(LGSTUpdateLOG)) continue; loggingThread->queueLog(&req); } resp.setStatusCode(0); resp.setStatusMessage("Log will be updated."); } catch (IException* e) { StringBuffer errorStr; e->errorMessage(errorStr); ERRLOG("Failed to update log: cannot add to log queue: %s",errorStr.str()); resp.setStatusCode(-1); resp.setStatusMessage(errorStr.str()); e->Release(); } return true; }
bool CWsLoggingServiceEx::onGetTransactionSeed(IEspContext& context, IEspGetTransactionSeedRequest& req, IEspGetTransactionSeedResponse& resp) { bool bRet = false; try { if (!context.validateFeatureAccess(WSLOGGING_ACCESS, SecAccess_Write, false)) throw MakeStringException(EspLoggingErrors::WSLoggingAccessDenied, "Failed to get transaction seed. Permission denied."); LOGServiceType serviceType = LGSTGetTransactionSeed; for (unsigned int x = 0; x < loggingAgentThreads.size(); x++) { IUpdateLogThread* loggingThread = loggingAgentThreads[x]; if (!loggingThread->hasService(serviceType)) continue; IEspLogAgent* loggingAgent = loggingThread->getLogAgent(); bRet = loggingAgent->getTransactionSeed(req, resp); break; } } catch (IException* e) { StringBuffer errorStr; e->errorMessage(errorStr); errorStr.insert(0, "Failed to get Transaction Seed: "); ERRLOG("%s", errorStr.str()); resp.setStatusCode(-1); resp.setStatusMessage(errorStr.str()); e->Release(); } return bRet; }
bool CLoggingManager::getTransactionID(StringAttrMapping* transFields, StringBuffer& transactionID, StringBuffer& status) { if (!initialized) throw MakeStringException(-1,"LoggingManager not initialized"); try { for (unsigned int x = 0; x < loggingAgentThreads.size(); x++) { IUpdateLogThread* loggingThread = loggingAgentThreads[x]; if (!loggingThread->hasService(LGSTGetTransactionID)) continue; IEspLogAgent* loggingAgent = loggingThread->getLogAgent(); loggingAgent->getTransactionID(transFields, transactionID); if (!transactionID.isEmpty()) ESPLOG(LogMax, "Got TransactionID '%s'", transactionID.str()); return true; } } catch (IException* e) { e->errorMessage(status); e->Release(); } return false; }
bool CLoggingManager::getTransactionSeed(IEspGetTransactionSeedRequest& req, IEspGetTransactionSeedResponse& resp) { if (!initialized) throw MakeStringException(-1,"LoggingManager not initialized"); bool bRet = false; try { for (unsigned int x = 0; x < loggingAgentThreads.size(); x++) { IUpdateLogThread* loggingThread = loggingAgentThreads[x]; if (!loggingThread->hasService(LGSTGetTransactionSeed)) continue; IEspLogAgent* loggingAgent = loggingThread->getLogAgent(); bRet = loggingAgent->getTransactionSeed(req, resp); if (bRet) break; } } catch (IException* e) { StringBuffer errorStr; e->errorMessage(errorStr); ERRLOG("Failed to get Transaction Seed: %s",errorStr.str()); resp.setStatusCode(-1); resp.setStatusMessage(errorStr.str()); e->Release(); } return bRet; }
bool CLoggingManager::updateLog(IEspContext* espContext, IEspUpdateLogRequestWrap& req, IEspUpdateLogResponse& resp) { if (!initialized) throw MakeStringException(-1,"LoggingManager not initialized"); bool bRet = false; try { if (espContext) espContext->addTraceSummaryTimeStamp(LogMin, "LMgr:startQLog"); for (unsigned int x = 0; x < loggingAgentThreads.size(); x++) { IUpdateLogThread* loggingThread = loggingAgentThreads[x]; if (loggingThread->hasService(LGSTUpdateLOG)) { loggingThread->queueLog(&req); bRet = true; } } if (espContext) espContext->addTraceSummaryTimeStamp(LogMin, "LMgr:endQLog"); } catch (IException* e) { StringBuffer errorStr; e->errorMessage(errorStr); ERRLOG("Failed to update log: %s",errorStr.str()); resp.setStatusCode(-1); resp.setStatusMessage(errorStr.str()); e->Release(); } return bRet; }
bool CLoggingManager::updateLog(IEspContext* espContext, IEspUpdateLogRequestWrap& req, IEspUpdateLogResponse& resp) { if (!initialized) throw MakeStringException(-1,"LoggingManager not initialized"); try { if (espContext) espContext->addTraceSummaryTimeStamp(LogMin, "LMgr:startQLog"); if (oneTankFile) { Owned<CLogRequestInFile> reqInFile = new CLogRequestInFile(); if (!saveToTankFile(req, reqInFile)) throw MakeStringException(-1, "LoggingManager: failed in saveToTankFile()."); //Build new log request for logging agents StringBuffer logContent, v; appendXMLOpenTag(logContent, LOGCONTENTINFILE); appendXMLTag(logContent, LOGCONTENTINFILE_FILENAME, reqInFile->getFileName()); appendXMLTag(logContent, LOGCONTENTINFILE_FILEPOS, v.append(reqInFile->getPos())); appendXMLTag(logContent, LOGCONTENTINFILE_FILESIZE, v.clear().append(reqInFile->getSize())); appendXMLTag(logContent, LOGREQUEST_GUID, reqInFile->getGUID()); appendXMLCloseTag(logContent, LOGCONTENTINFILE); Owned<IEspUpdateLogRequest> logRequest = new CUpdateLogRequest("", ""); logRequest->setOption(reqInFile->getOption()); logRequest->setLogContent(logContent); for (unsigned int x = 0; x < loggingAgentThreads.size(); x++) { IUpdateLogThread* loggingThread = loggingAgentThreads[x]; if (loggingThread->hasService(LGSTUpdateLOG)) { loggingThread->queueLog(logRequest); } } } else { for (unsigned int x = 0; x < loggingAgentThreads.size(); x++) { IUpdateLogThread* loggingThread = loggingAgentThreads[x]; if (loggingThread->hasService(LGSTUpdateLOG)) { loggingThread->queueLog(&req); } } } if (espContext) espContext->addTraceSummaryTimeStamp(LogMin, "LMgr:endQLog"); } catch (IException* e) { StringBuffer errorStr; e->errorMessage(errorStr); ERRLOG("Failed to update log: %s",errorStr.str()); resp.setStatusCode(-1); resp.setStatusMessage(errorStr.str()); e->Release(); } return true; }