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 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"); 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; }