void SyslogParser::parseNew(const std::string& msg, RemoteSyslogChannel::Severity severity, RemoteSyslogChannel::Facility fac, std::size_t& pos) { Poco::Message::Priority prio = convert(severity); // rest of the unparsed header is: // VERSION SP TIMESTAMP SP HOSTNAME SP APP-NAME SP PROCID SP MSGID std::string versionStr(parseUntilSpace(msg, pos)); std::string timeStr(parseUntilSpace(msg, pos)); // can be the nilvalue! std::string hostName(parseUntilSpace(msg, pos)); std::string appName(parseUntilSpace(msg, pos)); std::string procId(parseUntilSpace(msg, pos)); std::string msgId(parseUntilSpace(msg, pos)); std::string message(msg.substr(pos)); pos = msg.size(); Poco::DateTime date; int tzd = 0; bool hasDate = Poco::DateTimeParser::tryParse(RemoteSyslogChannel::SYSLOG_TIMEFORMAT, timeStr, date, tzd); Poco::Message logEntry(msgId, message, prio); logEntry["host"] = hostName; logEntry["app"] = appName; if (hasDate) logEntry.setTime(date.timestamp()); int lval(0); Poco::NumberParser::tryParse(procId, lval); logEntry.setPid(lval); _pListener->log(logEntry); }
logEntry::logEntry(String r) { std::vector<String> split = r.split(' '); if(split.size() == 10) { _host = split[0]; _status = split[8]; _request = split[6]; _number_of_bytes = atoi(split[9].get_array()); std::vector<String> dateTime = split[3].split(':'); _time = Time( atoi(dateTime[1].get_array()), atoi(dateTime[2].get_array()), atoi(dateTime[3].get_array()) ); std::vector<String> date = dateTime[0].split('/'); _date = Date( date[1], atoi(date[0].substr(1,2).get_array()), atoi(date[2].get_array()) ); } else { logEntry(); } }
void FileLogger::logEntry(TCHAR * msg) { TCHAR locationTag[] = _T("None"); logEntry(msg,locationTag); // TimeData time; // time.setToCurrentTime(); // fwprintf(logfp,_T("\n%d:%d:%d:%d:\t%s"),time.hours,time.mins,time.seconds,time.miliseconds,msg); }
void FileLogger::logEntry(const char * msg) { char locationTag[] = "None"; logEntry(msg,locationTag); // TimeData time; // time.setToCurrentTime(); // fprintf(logfp,"\n%d:%d:%d:%d:\t%s",time.hours,time.mins,time.seconds,time.miliseconds,msg); }
void log(const std::string & message, unsigned int level, const std::string & category){ //we are moving it, it cannot be const LogEntry logEntry(message,category, level); if (_logLevel<=logEntry.level) std::cout << "mcbLog: "<< logEntry.stringValue() << std::endl; if (_analyticsHandler && level==LogLevelAnalytics) { _analyticsHandler(logEntry); if (_isRecordingLog) _logEntries.emplace_back(std::move(logEntry)); } }
/// insert P to the label of N; do necessary updates; may return Clash in case of data node N bool DlSatTester :: insertToDoEntry ( DlCompletionTree* node, const ConceptWDep& C, DagTag tag, const char* reason = NULL ) { // we will change current Node => save it if necessary updateLevel ( node, C.getDep() ); CGraph.addConceptToNode ( node, C, tag ); setUsed(C.bp()); if ( node->isCached() ) return correctCachedEntry(node); // add new info in TODO list TODO.addEntry ( node, tag, C ); if ( node->isDataNode() ) // data concept -- run data center for it return checkDataNode ? checkDataClash(node) : false; else if ( LLM.isWritable(llGTA) ) // inform about it logEntry ( node, C, reason ); return false; }
////////////////////////////////////////////////////////// // PRE: // POST: // std::vector<logEntry> parse(std::istream& in) { std::vector<logEntry> result; int i=0; while(! in.eof()) { char temp; String raw(""); in >> temp; while(temp != '\n' && !in.eof()) { raw += String(temp); in.get(temp); } if(raw != String()) { std::cout << "Parsing Record: " << i << "\r"; ++i; result.push_back(logEntry(raw)); } } return result; }
void SyslogParser::parseBSD(const std::string& msg, RemoteSyslogChannel::Severity severity, RemoteSyslogChannel::Facility fac, std::size_t& pos) { Poco::Message::Priority prio = convert(severity); // rest of the unparsed header is: // "%b %f %H:%M:%S" SP hostname|ipaddress // detect three spaces int spaceCnt = 0; std::size_t start = pos; while (spaceCnt < 3 && pos < msg.size()) { if (msg[pos] == ' ') { spaceCnt++; if (spaceCnt == 1) { // size must be 3 chars for month if (pos - start != 3) { // probably a shortened time value, or the hostname // assume hostName Poco::Message logEntry(msg.substr(start, pos-start), msg.substr(pos+1), prio); _pListener->log(logEntry); return; } } else if (spaceCnt == 2) { // a day value! if (!(std::isdigit(msg[pos-1]) && (std::isdigit(msg[pos-2]) || std::isspace(msg[pos-2])))) { // assume the next field is a hostname spaceCnt = 3; } } if (pos + 1 < msg.size() && msg[pos+1] == ' ') { // we have two spaces when the day value is smaller than 10! ++pos; // skip one } } ++pos; } std::string timeStr(msg.substr(start, pos-start-1)); int tzd(0); Poco::DateTime date; int year = date.year(); // year is not included, use the current one bool hasDate = Poco::DateTimeParser::tryParse(RemoteSyslogChannel::BSD_TIMEFORMAT, timeStr, date, tzd); if (hasDate) { int m = date.month(); int d = date.day(); int h = date.hour(); int min = date.minute(); int sec = date.second(); date = Poco::DateTime(year, m, d, h, min, sec); } // next entry is host SP std::string hostName(parseUntilSpace(msg, pos)); // TAG: at most 32 alphanumeric chars, ANY non alphannumeric indicates start of message content // ignore: treat everything as content std::string message(msg.substr(pos)); pos = msg.size(); Poco::Message logEntry(hostName, message, prio); logEntry.setTime(date.timestamp()); _pListener->log(logEntry); }
void VDBFlushMgr::MainLoop() { VDebugContext& context = VTask::GetCurrent()->GetDebugContext(); context.StartLowLevelMode(); sLONG nbpass = 1; Boolean AuMoinsUnFlushTreeNonVide; fIsFlushing = true; if (VDBMgr::GetActivityManager() != nil) VDBMgr::GetActivityManager()->SetActivityWrite(true, -1); /* VGoldfingerSysTrayServer* systray = VGoldfingerSysTrayServer::GetSysTray(); if ( NULL != systray ) systray->SetActivityWrite_Toggle(true); */ VCacheLogQuotedEntry logEntry(eCLEntryKind_Flush, false, true); #if trackClose trackDebugMsg("debut flush MainLoop\n"); #endif while (nbpass<2) { uLONG WaitOthers = 1; //fFlushedBytes = 0; AuMoinsUnFlushTreeNonVide = true; FlushProgressInfo fpi; fpi.curObjectNum = 0; fpi.totbytes = 0; fpi.starttime = VSystem::GetCurrentTime(); fpi.lasttime = fpi.starttime; fpi.currentBD = nil; #if debuglr == 101 if (fFlushProgress != nil && !fFlushProgress->IsManagerValid()) { sLONG xdebug = 1; // put a break here } if (fFlushProgress != nil) fFlushProgress->Release(); #endif fFlushProgress = VDBMgr::GetManager()->RetainDefaultProgressIndicator_For_DataCacheFlushing(); if (fFlushProgress != nil) { XBOX::VString session_title; gs(1005,22,session_title); // Flushing Data fpi.message = session_title; fFlushProgress->BeginSession(sGlobalNbFlushObjects,session_title,false); } Boolean RAZTimers = true; SetCurTaskFlushing(true); while( AuMoinsUnFlushTreeNonVide) { Boolean AllisSomethingFlushed = false; Boolean toutvide = true, waitForRequestForInvalid = false; SetDirty( false); //xSetFlushCancelled( false); BaseFlushInfo *curinfo; { VTaskLock Lock(&ListFlushInfoMutext); curinfo = ListFlushInfo; } while (curinfo != nil) { Boolean isSomethingFlushed = false; BtreeFlush *newbtflush; Boolean mustincreasetimer = false; sLONG NbModifStamp = 0; DataAddrSetVector AllSegsFullyDeletedObjects; { VTaskLock Lock(&(curinfo->TreeMutex)); if (RAZTimers) { curinfo->fWaitToInsertNewObject = 0; curinfo->fWaitToInsertNewObjectTimer.Unlock(); } newbtflush = curinfo->fCurTree; curinfo->fFlushingTree = newbtflush; curinfo->fCurTree = nil; if (newbtflush != nil) { fpi.currentBD = curinfo->GetOwner(); curinfo->GetOwner()->SwapAllSegsFullyDeletedObjects(AllSegsFullyDeletedObjects); if (fNeedValidate.find(curinfo) == fNeedValidate.end()) { curinfo->GetOwner()->InvalidateHeader(); fNeedValidate.insert(curinfo); } } else { if (curinfo->fRequestForInvalid > 0) { waitForRequestForInvalid = true; if (fNeedValidate.find(curinfo) == fNeedValidate.end()) { curinfo->GetOwner()->InvalidateHeader(); fNeedValidate.insert(curinfo); } } } NbModifStamp = curinfo->fNbModifStamp; } if (newbtflush != nil) { VSize curtot = 0; if (newbtflush->ViderFlush( &curtot, &isSomethingFlushed, &events, &FlushEventMutex, fFlushProgress, fpi, AllSegsFullyDeletedObjects)) { // comme tout l'arbre a ete flushe, on peut le supprimer xDisposeFlushingTree( curinfo, false); newbtflush=nil; } else toutvide = false; for (DataAddrSetVector::iterator cur = AllSegsFullyDeletedObjects.begin(), end = AllSegsFullyDeletedObjects.end(); cur != end; cur++) { DataAddrSetForFlush* px = &(*cur); if (!px->fAddrs.empty()) { sLONG nullzero = 0; while (px->fCurrent != px->fLast ) { fpi.currentBD->writelong(&nullzero, 4, *(px->fCurrent), 0); px->fCurrent++; } } } if (NbModifStamp != curinfo->fNbModifStamp) mustincreasetimer = true; if (newbtflush!=nil) { // comme certains objets n'ont pu etre flushe, on recopie le residu d'arbre pour un prochain essai xDisposeFlushingTree( curinfo, true); newbtflush=nil; toutvide = false; } AllisSomethingFlushed = AllisSomethingFlushed || isSomethingFlushed; { VTaskLock Lock(&(curinfo->TreeMutex)); if (curinfo->fCurTree == nil) { if (curinfo->fRequestForInvalid > 0) { waitForRequestForInvalid = true; } else { fNeedValidate.erase(curinfo); curinfo->GetOwner()->ValidateHeader(); } curinfo->fWaitToInsertNewObject = 0; curinfo->fWaitToInsertNewObjectTimer.Unlock(); } else { if (mustincreasetimer) { if (curinfo->fWaitToInsertNewObject == 0) { curinfo->fWaitToInsertNewObject = 1; curinfo->fLastTimeIncrease = VSystem::GetCurrentTime(); curinfo->fWaitToInsertNewObjectTimer.ResetAndLock(); } else { uLONG curtime = VSystem::GetCurrentTime(); if ((uLONG)abs((sLONG)(curtime - curinfo->fLastTimeIncrease)) > curinfo->fWaitToInsertNewObject) { if (curinfo->fWaitToInsertNewObject < 8192) curinfo->fWaitToInsertNewObject = curinfo->fWaitToInsertNewObject * 2; curinfo->fLastTimeIncrease = curtime; } } } else // decrease { if (curinfo->fWaitToInsertNewObject != 0) { if (curinfo->fWaitToInsertNewObject == 1) { curinfo->fWaitToInsertNewObject = 0; curinfo->fWaitToInsertNewObjectTimer.Unlock(); } else { uLONG curtime = VSystem::GetCurrentTime(); if ((uLONG)abs((sLONG)(curtime - curinfo->fLastTimeIncrease)) > curinfo->fWaitToInsertNewObject) { curinfo->fWaitToInsertNewObject = curinfo->fWaitToInsertNewObject / 2; curinfo->fLastTimeIncrease = curtime; } } } } toutvide = false; } } } { VTaskLock Lock(&(curinfo->TreeMutex)); curinfo = curinfo->right; } } // on libere toute les demandes de flush pour memoire qui ont, au moins, fait un cycle complet { VTaskLock lock2(&FlushEventMutex); for (FlushEventList::iterator cur = events.begin(), end = events.end(); cur != end; ) { Boolean next = true; if (cur->needmem) { if (cur->FlushCycle!= fCurrentFlushCycle) { cur->flag->Unlock(); cur->flag->Release(); FlushEventList::iterator theone = cur; cur++; next = false; events.erase(theone); } } if (next) cur++; } fCurrentFlushCycle++; } // maintenant on supprime les BaseFlushInfo des bases qu'on a ferme { VTaskLock Lock(&ListFlushInfoMutext); curinfo = ListFlushInfo; while (curinfo != nil) { Boolean doisdelete = false; BaseFlushInfo* suivant; { VTaskLock Lock2(&(curinfo->TreeMutex)); suivant = curinfo->right; doisdelete = (curinfo->doisdelete); if (doisdelete) DeleteBaseFlushInfo(curinfo); } curinfo = suivant; } } { VTaskLock lock2(&FlushEventMutex); for (FlushEventList::iterator cur = events.begin(), end = events.end(); cur != end; ) { Boolean next = true; if (cur->waitForAllWritten) { cur->flag->Unlock(); cur->flag->Release(); FlushEventList::iterator theone = cur; cur++; next = false; events.erase(theone); } if (next) cur++; } } if (toutvide) { if (waitForRequestForInvalid) AuMoinsUnFlushTreeNonVide = true; else AuMoinsUnFlushTreeNonVide = false; // on peut quitter la boucle car tous les arbres ont ete flushes } else { if (WaitOthers < 2) WaitOthers = WaitOthers * 2; VTask::GetCurrent()->Sleep(WaitOthers); //vYieldNow(); //on donne une chance aux autres process de liberer les objets lockes } VDBMgr::GetCacheManager()->ClearWaitListForBigObject(); RAZTimers = false; VDBMgr::GetManager()->PurgeExpiredDataSets(); VDBMgr::GetManager()->DeleteDeadBlobPaths(); } if (fFlushProgress != nil) { fFlushProgress->EndSession(); #if debuglr == 101 // when debugging, keep the progress indicator #else fFlushProgress->Release(); fFlushProgress = nil; #endif } SetCurTaskFlushing(false); //SetDirty( false); ++nbpass; } #if trackClose trackDebugMsg("fin flush MainLoop\n"); #endif xFlushEnd(); #if trackClose trackDebugMsg("apres xFlushEnd\n"); #endif if (VDBMgr::GetActivityManager() != nil) VDBMgr::GetActivityManager()->SetActivityWrite(false, 0); /* if ( NULL != systray ) systray->SetActivityWrite_Toggle(false); */ VDBMgr::GetManager()->FlushAllData(); context.StopLowLevelMode(); }