diff --git a/.gitignore b/.gitignore index 01e00f3..b727816 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ CMakeLists.txt.user +cmake/* +build/ diff --git a/Essentials/pLogger/MOOSLogger.cpp b/Essentials/pLogger/MOOSLogger.cpp index bf3f19c..d7ec892 100644 --- a/Essentials/pLogger/MOOSLogger.cpp +++ b/Essentials/pLogger/MOOSLogger.cpp @@ -77,8 +77,8 @@ using namespace std; CMOOSLogger::CMOOSLogger() { - - + + //be default we don't need to be too fast.. SetAppFreq(5); @@ -111,7 +111,7 @@ CMOOSLogger::CMOOSLogger() //and append a time ot the stem m_bAppendFileTimeStamp = true; - + //by default use local time for directory names m_bUseUTCLogNames = false; @@ -120,10 +120,19 @@ CMOOSLogger::CMOOSLogger() //by default to not mark (with a @) variables being sent from external communities m_bMarkExternalCommunityMessages= false; - + //by default do not indicate data tyep with a D: or S: suffix m_bMarkDataType = false; + //by default, space header lines by 30 entries between + m_nSyncLogHeaderSpacing = 30; + + //by default, insert intermediate headers into sync logs + m_bAddIntermediateHeaders = true; + + //by default, replace stale variables with NaN + m_bIncludeStale = false; + //lets always sort mail by time... SortMailByTime(true); @@ -157,13 +166,13 @@ bool CMOOSLogger::CloseFiles() { m_SystemLogFile.close(); } - + //crucially make sure teh zipping thread has stopped #ifdef ZLIB_FOUND - + m_AlogZipper.Stop(); - + if(m_bUseExcludedLog) { m_XlogZipper.Stop(); @@ -231,7 +240,7 @@ bool CMOOSLogger::OnStartUp() { MOOSRemoveChars(sTmp," "); string sBool = MOOSChomp(sTmp,"@"); - + m_bSynchronousLog = MOOSStrCmp(sBool,"TRUE"); //look for an additional parameter saying how often to log... @@ -252,30 +261,36 @@ bool CMOOSLogger::OnStartUp() //are we required to perform Asynchronous logs? m_MissionReader.GetConfigurationParam("ASYNCLOG",m_bAsynchronousLog); - + //are we required to run an exclusion log (which is where wildcard rejections can be sent //for paranoid people m_MissionReader.GetConfigurationParam("WildcardExclusionLog",m_bUseExcludedLog); - + //what sort of file name are we using m_MissionReader.GetConfigurationParam("FILETIMESTAMP",m_bAppendFileTimeStamp); - + //do we want to use UTC times in directory names m_MissionReader.GetConfigurationParam("UTCLogDirectories",m_bUseUTCLogNames); - + //where should we write a summary of where we are logging to? m_sSummaryFile = "./.LastOpenedMOOSLogDirectory"; m_MissionReader.GetConfigurationParam("LoggingDirectorySummaryFile",m_sSummaryFile); - + m_nDoublePrecision = DEFAULT_DOUBLE_PRECISION; m_MissionReader.GetConfigurationParam("DoublePrecision",m_nDoublePrecision); - + m_MissionReader.GetConfigurationParam("LogAuxSrc",m_bLogAuxSrc); - + m_MissionReader.GetConfigurationParam("MarkExternalCommunityMessages",m_bMarkExternalCommunityMessages); m_MissionReader.GetConfigurationParam("MarkDataType",m_bMarkDataType); + m_MissionReader.GetConfigurationParam("SyncLogHeaderSpacing", m_nSyncLogHeaderSpacing); + + m_MissionReader.GetConfigurationParam("SyncLogIntermediateHeaders", m_bAddIntermediateHeaders); + + m_MissionReader.GetConfigurationParam("IncludeStaleVariables", m_bIncludeStale); + //do we have a path global name? if(!m_MissionReader.GetValue("GLOBALLOGPATH",m_sPath)) { @@ -308,7 +323,7 @@ bool CMOOSLogger::OnStartUp() //do we want to do zip logging m_bCompressAlog = false; m_MissionReader.GetConfigurationParam("CompressAlogs",m_bCompressAlog); - + if(m_bCompressAlog) { #ifndef ZLIB_FOUND @@ -316,7 +331,7 @@ bool CMOOSLogger::OnStartUp() MOOSTrace("warning:\n\talogs will not be compressed because zlib was not found at build time"); #endif } - + @@ -354,7 +369,7 @@ bool CMOOSLogger::ConfigureLogging() std::string sNewVar; HandleLogRequest(sParam,sNewVar); } - + } } else @@ -393,14 +408,14 @@ bool CMOOSLogger::ConfigureLogging() m_bWildCardLogging = true; } - + //what sort of things do we want to wild card log if(m_bWildCardLogging ) { - + //we never want to log mission files sent between communities - this is done elsewhere m_sWildCardOmitted.push_back("MISSION_FILE"); - + //there was a request to allow multiple statements of the these patterns...hence the //more complicated parsing here STRING_LIST sList; @@ -413,7 +428,7 @@ bool CMOOSLogger::ConfigureLogging() std::string sTok,sVal; if(!CMOOSFileReader::GetTokenValPair(*q, sTok,sVal)) continue; - + if(MOOSStrCmp("WildCardPattern",sTok)) { while(!sVal.empty()) @@ -430,8 +445,8 @@ bool CMOOSLogger::ConfigureLogging() } } } - - + + m_bAsynchronousLog = true; } @@ -571,7 +586,7 @@ bool CMOOSLogger::HandleWildCardLogging() bool bWouldNormallyReject = IsWildCardRejected(sVar); bool bWouldNormallyAccept = IsWildCardAccepted(sVar); bool bWanted = false; - + if(m_bUseExcludedLog) { bWanted = true; @@ -580,14 +595,14 @@ bool CMOOSLogger::HandleWildCardLogging() MOOSTrace(" Added wildcard logging of %-20s\n",sVar.c_str()); m_LogDestinations[sVar] = ALOG; } - else + else { MOOSTrace(" Added wildcard logging of %-20s (xlog) \n",sVar.c_str()); m_LogDestinations[sVar] = XLOG; - + } } - + else { if( bWouldNormallyAccept && !bWouldNormallyReject ) @@ -598,20 +613,20 @@ bool CMOOSLogger::HandleWildCardLogging() } else if(bWouldNormallyAccept && bWouldNormallyReject) { - //MOOSTrace(" denied added wildcard logging of %-20s (fits Omit pattern as well as Accept pattern)\n",sVar.c_str()); + //MOOSTrace(" denied added wildcard logging of %-20s (fits Omit pattern as well as Accept pattern)\n",sVar.c_str()); bWanted = false; } } - + if(bWanted) { //yep we want to know.... if(AddMOOSVariable(sVar,sVar,"",0.0)) { bHit = true; - } + } } - + } } @@ -642,23 +657,23 @@ struct StringMatcher bool CMOOSLogger::IsWildCardRejected(const std::string & sVariableName) const { return std::find_if(m_sWildCardOmitted.begin(), - m_sWildCardOmitted.end(), + m_sWildCardOmitted.end(), StringMatcher(sVariableName)) !=m_sWildCardOmitted.end(); } bool CMOOSLogger::IsWildCardAccepted(const std::string & sVariableName) const { - + //we assume by default we want everything if(m_sWildCardAccepted.empty()) return true; - + //looks like some masks have been set return std::find_if(m_sWildCardAccepted.begin(), - m_sWildCardAccepted.end(), + m_sWildCardAccepted.end(), StringMatcher(sVariableName)) !=m_sWildCardAccepted.end(); - + } @@ -667,7 +682,7 @@ std::string CMOOSLogger::MakeLogName(string sStem) struct tm *Now; time_t aclock; time( &aclock ); - + if(m_bUseUTCLogNames) { Now = gmtime(&aclock); @@ -683,11 +698,11 @@ std::string CMOOSLogger::MakeLogName(string sStem) { // Print local time as a string - sTmp = MOOSFormat( "%s_%d_%d_%d_____%.2d_%.2d_%.2d", + sTmp = MOOSFormat( "%s_%d_%02d_%02d_____%.2d_%.2d_%.2d", sStem.c_str(), - Now->tm_mday, - Now->tm_mon+1, Now->tm_year+1900, + Now->tm_mon+1, + Now->tm_mday, Now->tm_hour, Now->tm_min, Now->tm_sec); @@ -732,7 +747,7 @@ bool CMOOSLogger::DoSyncLog(double dfTimeNow) m_SyncLogFile<::iterator q = m_LogDestinations.find(sMsg); if( q==m_LogDestinations.end()) return UNKNOWN; - else + else return q->second; - + } bool CMOOSLogger::DoAsyncLog(MOOSMSG_LIST &NewMail) @@ -1231,12 +1249,12 @@ bool CMOOSLogger::DoAsyncLog(MOOSMSG_LIST &NewMail) //which is used for the synchronous case.. if(m_MOOSVars.find(rMsg.m_sKey)!=m_MOOSVars.end()) { - - + + std::stringstream sEntry; - + sEntry.setf(ios::left); - + sEntry.setf(ios::fixed); sEntry<File="<<(m_sLogRootName+".blog")<<",Offset="<"; - + //write the binary data to file m_BinaryLogFile.write(rMsg.m_sVal.data(), rMsg.m_sVal.size()); - + //add a new line so even the binary log file is broadly human readable m_BinaryLogFile<