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 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 CESPServerLoggingAgent::updateLog(IEspUpdateLogRequestWrap& req, IEspUpdateLogResponse& resp) { try { StringBuffer soapreq( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"" " xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\">" " <soap:Body>" ); soapreq.append(req.getUpdateLogRequest()); soapreq.append("</soap:Body></soap:Envelope>"); StringBuffer status, respStr; if (sendHTTPRequest(soapreq, respStr, status) && status.length() && strieq(status, "200 OK")) resp.setStatusCode(0); else if (status.length() && !strieq(status, "200 OK")) throw MakeStringException(EspLoggingErrors::UpdateLogFailed, "%s", status.str()); else if (respStr.length()) throw MakeStringException(EspLoggingErrors::UpdateLogFailed, "%s", respStr.str()); else throw MakeStringException(EspLoggingErrors::UpdateLogFailed, "Failed to send update log request to %s", serverUrl.str()); } catch (IException* e) {//retry will be in update log queue. StringBuffer errorStr, errorMessage; errorMessage.append("Failed to update log: error code ").append(e->errorCode()).append(", error message ").append(e->errorMessage(errorStr)); ERRLOG("%s", errorMessage.str()); resp.setStatusCode(-1); resp.setStatusMessage(errorMessage.str()); e->Release(); } return true; }
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; }