API
 
Loading...
Searching...
No Matches
MagAOX::logger::logMap< verboseT > Struct Template Reference

Map of log entries by application name, mapping both to files and to loaded buffers. More...

#include <logMap.hpp>

Collaboration diagram for MagAOX::logger::logMap< verboseT >:
Collaboration graph

Public Types

typedef file::stdSubDir< verboseT > stdSubDirT
 
typedef file::stdFileName< verboseT > stdFileNameT
 
typedef std::map< std::string, std::set< stdFileNameT, file::compStdFileName< stdFileNameT > > > appToFileMapT
 The app-name to file-name map type, for sorting the input files by application.
 
typedef std::map< std::string, logInMemoryappToBufferMapT
 The app-name to buffer map type, for looking up the currently loaded logs for a given app.
 

Public Member Functions

mx::error_t addFileListToFileMap (const std::string &dev, const std::vector< std::string > &flist, size_t n0, size_t nf)
 Add a list of files to the file map.
 
mx::error_t loadAppToFileMap (const std::string &dir, const std::string &dev, const std::string &ext, const stdFileNameT &firstFile, const stdFileNameT &lastFile)
 Get log file names in a directory and distribute them into the map by app-name.
 
int getPriorLog (char *&logBefore, const std::string &appName, const flatlogs::eventCodeT &ev, const flatlogs::timespecX &ts, char *hint=0)
 Get the log for an event code which is the first prior to the supplied time.
 
int getNextLog (char *&logAfter, char *logCurrent, const std::string &appName)
 Get the next log with the same event code which is after the supplied time.
 
int getNearestLogs (flatlogs::bufferPtrT &logBefore, flatlogs::bufferPtrT &logAfter, const std::string &appName)
 
int loadFiles (const std::string &appName, const flatlogs::timespecX &startTime)
 

Public Attributes

appToFileMapT m_appToFileMap
 
appToBufferMapT m_appToBufferMap
 

Detailed Description

template<class verboseT = XWC_DEFAULT_VERBOSITY>
struct MagAOX::logger::logMap< verboseT >

Map of log entries by application name, mapping both to files and to loaded buffers.

Definition at line 50 of file logMap.hpp.

Member Typedef Documentation

◆ appToBufferMapT

template<class verboseT = XWC_DEFAULT_VERBOSITY>
typedef std::map<std::string, logInMemory> MagAOX::logger::logMap< verboseT >::appToBufferMapT

The app-name to buffer map type, for looking up the currently loaded logs for a given app.

Definition at line 60 of file logMap.hpp.

◆ appToFileMapT

template<class verboseT = XWC_DEFAULT_VERBOSITY>
typedef std::map<std::string, std::set<stdFileNameT, file::compStdFileName<stdFileNameT> > > MagAOX::logger::logMap< verboseT >::appToFileMapT

The app-name to file-name map type, for sorting the input files by application.

Definition at line 57 of file logMap.hpp.

◆ stdFileNameT

template<class verboseT = XWC_DEFAULT_VERBOSITY>
typedef file::stdFileName<verboseT> MagAOX::logger::logMap< verboseT >::stdFileNameT

Definition at line 54 of file logMap.hpp.

◆ stdSubDirT

template<class verboseT = XWC_DEFAULT_VERBOSITY>
typedef file::stdSubDir<verboseT> MagAOX::logger::logMap< verboseT >::stdSubDirT

Definition at line 53 of file logMap.hpp.

Member Function Documentation

◆ addFileListToFileMap()

template<class verboseT >
mx::error_t MagAOX::logger::logMap< verboseT >::addFileListToFileMap ( const std::string &  dev,
const std::vector< std::string > &  flist,
size_t  n0,
size_t  nf 
)

Add a list of files to the file map.

This is a worker function for loadAppToFileMap

Returns
mx::error_t::noerror on success
mx::error_t::std_exception if a std::exception is thrown
Parameters
[in]devthe device name to add
[in]flistthe file list from which to add files
[in]n0the first entry in the file list to add
[in]nfone past the last entry in the file list to add, e.g. flist.size()

Definition at line 118 of file logMap.hpp.

References MagAOX::file::stdFileName< verboseT >::appName(), MagAOX::file::stdFileName< verboseT >::valid(), and MagAOX::xwcException::what().

◆ getNearestLogs()

template<class verboseT = XWC_DEFAULT_VERBOSITY>
int MagAOX::logger::logMap< verboseT >::getNearestLogs ( flatlogs::bufferPtrT logBefore,
flatlogs::bufferPtrT logAfter,
const std::string &  appName 
)

◆ getNextLog()

template<class verboseT >
int MagAOX::logger::logMap< verboseT >::getNextLog ( char *&  logAfter,
char *  logCurrent,
const std::string &  appName 
)

Get the next log with the same event code which is after the supplied time.

Parameters
[out]logAfterpointer to the first byte of the prior log entry
[in]logCurrentThe log to start from
[in]appNamethe name of the app specifying which log to search

Definition at line 634 of file logMap.hpp.

References flatlogs::logHeader::eventCode(), MagAOX::logger::logInMemory::m_memory, and flatlogs::logHeader::totalSize().

Referenced by MagAOX::logger::getLogContVal(), and MagAOX::logger::getLogStateVal().

◆ getPriorLog()

template<class verboseT >
int MagAOX::logger::logMap< verboseT >::getPriorLog ( char *&  logBefore,
const std::string &  appName,
const flatlogs::eventCodeT ev,
const flatlogs::timespecX ts,
char *  hint = 0 
)

Get the log for an event code which is the first prior to the supplied time.

Parameters
[out]logBeforepointer to the first byte of the prior log entry
[in]appNamethe name of the app specifying which log to search
[in]evthe event code to search for
[in]tsthe timestamp to be prior to
[in]hint[optional] a hint specifying where to start searching. If null search starts at beginning.

Definition at line 510 of file logMap.hpp.

References flatlogs::logHeader::eventCode(), MagAOX::logger::logInMemory::m_endTime, MagAOX::logger::logInMemory::m_memory, MagAOX::logger::logInMemory::m_startTime, flatlogs::timespecX::time_s, flatlogs::logHeader::timespec(), and flatlogs::logHeader::totalSize().

Referenced by MagAOX::logger::getLogContVal(), and MagAOX::logger::getLogStateVal().

◆ loadAppToFileMap()

template<class verboseT >
mx::error_t MagAOX::logger::logMap< verboseT >::loadAppToFileMap ( const std::string &  dir,
const std::string &  dev,
const std::string &  ext,
const stdFileNameT firstFile,
const stdFileNameT lastFile 
)

Get log file names in a directory and distribute them into the map by app-name.

Finding no logs is not reported as an error (no exception is thrown). You must check the size of m_appToFileMap to check if any files were found.

Parameters
[in]dirthe directory to search for files (contains the dev/YYYY_MM_DD subdirs)
[in]devthe device name to search for logs of
[in]extthe extension to search for
[in]firstFilethe first file that needs coverage
[in]lastFilethe last file that needs coverage

Definition at line 174 of file logMap.hpp.

References MagAOX::file::stdSubDir< verboseT >::addDay(), MagAOX::file::stdFileName< verboseT >::fullName(), MagAOX::file::stdSubDir< verboseT >::path(), MagAOX::file::stdSubDir< verboseT >::subDay(), MagAOX::file::stdFileName< verboseT >::subDir(), flatlogs::timespecX::time_s, MagAOX::file::stdFileName< verboseT >::timestamp(), and MagAOX::file::stdFileName< verboseT >::valid().

Referenced by libXWCTest::loggerTest::logMapTest::TEST_CASE(), libXWCTest::loggerTest::logMapTest::TEST_CASE(), and libXWCTest::loggerTest::logMapTest::TEST_CASE().

◆ loadFiles()

template<class verboseT >
int MagAOX::logger::logMap< verboseT >::loadFiles ( const std::string &  appName,
const flatlogs::timespecX startTime 
)
Parameters
appNameMagAO-X app name for which to load files

Definition at line 682 of file logMap.hpp.

Member Data Documentation

◆ m_appToBufferMap

template<class verboseT = XWC_DEFAULT_VERBOSITY>
appToBufferMapT MagAOX::logger::logMap< verboseT >::m_appToBufferMap

Definition at line 64 of file logMap.hpp.

◆ m_appToFileMap

template<class verboseT = XWC_DEFAULT_VERBOSITY>
appToFileMapT MagAOX::logger::logMap< verboseT >::m_appToFileMap

The documentation for this struct was generated from the following file: