OpenM++ runtime library (libopenm)
Loading...
Searching...
No Matches
openm::TraceLog Class Reference

trace log implementation class: model event log to console and into log files. More...

#include <log.h>

Inheritance diagram for openm::TraceLog:
Collaboration diagram for openm::TraceLog:

Public Member Functions

 TraceLog (bool i_logToConsole=false, const char *i_basePath="", bool i_logToFile=false, bool i_useTimeStamp=false, bool i_usePidStamp=false, bool i_noMsgTime=false)
 create log instance.
 
 ~TraceLog (void) noexcept
 cleanup trace log resources
 
void init (bool i_logToConsole, const char *i_basePath, bool i_logToFile, bool i_useTimeStamp=false, bool i_usePidStamp=false, bool i_noMsgTime=false) noexcept override
 re-initialize trace file name(s) and other log settings, it is also create or truncate existing trace file.
 
void logMsg (const char *i_msg, const char *i_extra=NULL) noexcept override
 log message
 
bool logFormatted (const char *i_format,...) noexcept override
 log message formatted with vsnprintf(), return false on error
 
- Public Member Functions inherited from openm::LogBase
 LogBase (bool i_logToConsole, const char *i_basePath, bool i_logToFile, bool i_useTimeStamp, bool i_usePidStamp, bool i_noMsgTime)
 create log instance.
 
 ~LogBase (void) noexcept
 cleanup log resources
 
const string timeStamp (void) noexcept override
 return timestamp part of log file name: 2012_08_17_16_04_59_148.
 
const bool isEnabled (void) noexcept override
 return true if log to console or to file enabled.
 
const bool isCreateError (void) noexcept override
 error at file create of last log or stamped log file
 
void init (bool i_logToConsole, const char *i_basePath, bool i_logToFile, bool i_useTimeStamp=false, bool i_usePidStamp=false, bool i_noMsgTime=false) noexcept
 re-initialize log file name(s) and other log settings.
 
void setRank (int i_rank, int i_worldSize) noexcept override
 use process rank as log message prefix
 

Additional Inherited Members

- Protected Member Functions inherited from openm::LogBase
bool doLogMsg (const char *i_msg, const char *i_extra) noexcept
 implement log message: log to console and log files
 
bool logFileCreate (const string &i_path) noexcept
 
bool writeToLog (ostream &i_ost, const chrono::system_clock::time_point &i_msgTime, const char *i_msg, const char *i_extra=nullptr)
 
- Protected Attributes inherited from openm::LogBase
recursive_mutex theMutex
 
bool isConsoleEnabled
 
bool isLastEnabled
 
bool isLastCreated
 
bool isErrorLastCreate
 
bool isStampedEnabled
 
bool isStampedCreated
 
bool isErrorStampedCreate
 
string tsPart
 
string pidPart
 
string lastPath
 
string stampedPath
 
bool isNoMsgTime
 
string rankPrefix
 
bool isMsgRank
 
char msgBuffer [msgBufferSize+1]
 
- Static Protected Attributes inherited from openm::LogBase
static const size_t msgBufferSize = 32768
 

Detailed Description

trace log implementation class: model event log to console and into log files.

trace log is faster than "regular" log but may not be flashed on runtime errors.
log can be enabled/disabled for 3 independent streams:
console - cout stream
"last run" file - log file with specified name, truncated on every model run
"stamped" file - log file with unique name, created for every model run

"stamped" name produced from "last run" name by adding time-stamp and pid-stamp, i.e.:
trace.log => trace.2012_08_17_16_04_59_148.1234.log

Constructor & Destructor Documentation

◆ TraceLog()

openm::TraceLog::TraceLog ( bool  i_logToConsole = false,
const char *  i_basePath = "",
bool  i_logToFile = false,
bool  i_useTimeStamp = false,
bool  i_usePidStamp = false,
bool  i_noMsgTime = false 
)
inline

create log instance.

Parameters
[in]i_logToConsoleif true then log to console
[in]i_basePathpath to "last" log file, if NULL or empty "" then no log file
[in]i_logToFileif true then enable log to "last" file
[in]i_useTimeStampif true then use timestamp suffix in "stamped" file name
[in]i_usePidStampif true then use PID suffix in "stamped" file name
[in]i_noMsgTimeif true then not prefix log messages with date-time

Member Function Documentation

◆ init()

void TraceLog::init ( bool  i_logToConsole,
const char *  i_basePath,
bool  i_logToFile,
bool  i_useTimeStamp = false,
bool  i_usePidStamp = false,
bool  i_noMsgTime = false 
)
overridevirtualnoexcept

re-initialize trace file name(s) and other log settings, it is also create or truncate existing trace file.

Parameters
[in]i_logToConsoleif true then trace to console
[in]i_basePathpath to "last" trace file, if NULL or empty "" then no trace file
[in]i_logToFileif true then enable log to "last" file
[in]i_useTimeStampif true then use timestamp suffix in "stamped" file name
[in]i_usePidStampif true then use PID suffix in "stamped" file name
[in]i_noMsgTimeif true then not prefix log messages with date-time
[in]i_logToConsoleif true then log to console
[in]i_basePathpath to "last" trace file, if NULL or empty "" then no trace file
[in]i_logToFileif true then enable log to "last" file
[in]i_useTimeStampif true then use timestamp suffix in "stamped" file name
[in]i_usePidStampif true then use PID suffix in "stamped" file name
[in]i_noMsgTimeif true then not prefix log messages with date-time

Implements openm::ITrace.

◆ logFormatted()

bool TraceLog::logFormatted ( const char *  i_format,
  ... 
)
overridevirtualnoexcept

log message formatted with vsnprintf(), return false on error

Implements openm::ILogBase.

◆ logMsg()

void TraceLog::logMsg ( const char *  i_msg,
const char *  i_extra = NULL 
)
overridevirtualnoexcept

log message

Implements openm::ILogBase.


The documentation for this class was generated from the following files: