28#pragma warning(disable : 4250)
49 const char * i_basePath,
61 const string timeStamp(
void)
noexcept override;
64 const bool isEnabled(
void)
noexcept override;
80 const char * i_basePath,
82 bool i_useTimeStamp =
false,
83 bool i_usePidStamp =
false,
84 bool i_noMsgTime =
false
88 void setRank(
int i_rank,
int i_worldSize)
noexcept override;
91 recursive_mutex theMutex;
92 bool isConsoleEnabled;
95 bool isErrorLastCreate;
96 bool isStampedEnabled;
97 bool isStampedCreated;
98 bool isErrorStampedCreate;
107 static const size_t msgBufferSize = 32768;
108 char msgBuffer[msgBufferSize + 1];
113 bool doLogMsg(
const char * i_msg,
const char * i_extra)
noexcept;
116 bool logFileCreate(
const string & i_path)
noexcept;
119 virtual bool logToConsole(
120 const chrono::system_clock::time_point & i_msgTime,
const char * i_msg,
const char * i_extra =
nullptr
124 virtual bool logToFile(
125 bool i_isToStamped,
const chrono::system_clock::time_point & i_msgTime,
const char * i_msg,
const char * i_extra =
nullptr
130 ostream & i_ost,
const chrono::system_clock::time_point & i_msgTime,
const char * i_msg,
const char * i_extra =
nullptr
162 bool i_logToConsole =
false,
163 const char * i_basePath =
"openm.log",
164 bool i_logToFile =
false,
165 bool i_useTimeStamp =
false,
166 bool i_usePidStamp =
false
183 const char * i_basePath,
185 bool i_useTimeStamp =
false,
186 bool i_usePidStamp =
false,
187 bool i_noMsgTime =
false,
188 bool i_isLogSql =
false
198 const string getMessage(
const char * i_sourceMsg)
noexcept override;
201 const list<string>
getLanguages(
void)
noexcept override;
207 void swapLanguageMessages(
const list<string> & i_langLst, unordered_map<string, string> & io_msgMap)
noexcept override;
210 void logMsg(
const char * i_msg,
const char * i_extra = NULL)
noexcept override;
213 bool logFormatted(
const char * i_format, ...)
noexcept override;
216 void logErr(
const exception & i_ex,
const char * i_msg =
nullptr)
noexcept override;
219 void logSql(
const char * i_sql)
noexcept override;
223 list<string> msgLangLst;
224 unordered_map<string, string> msgMap;
228 const chrono::system_clock::time_point & i_msgTime,
const char * i_msg,
const char * i_extra =
nullptr
233 bool i_isToStamped,
const chrono::system_clock::time_point & i_msgTime,
const char * i_msg,
const char * i_extra =
nullptr
237 Log(
const Log & i_log) =
delete;
238 Log & operator=(
const Log & i_log) =
delete;
268 bool i_logToConsole =
false,
269 const char * i_basePath =
"",
270 bool i_logToFile =
false,
271 bool i_useTimeStamp =
false,
272 bool i_usePidStamp =
false,
273 bool i_noMsgTime =
false
274 ) :
LogBase(i_logToConsole, i_basePath, i_logToFile, i_useTimeStamp, i_usePidStamp, i_noMsgTime)
290 const char * i_basePath,
292 bool i_useTimeStamp =
false,
293 bool i_usePidStamp =
false,
294 bool i_noMsgTime =
false
298 void logMsg(const
char * i_msg, const
char * i_extra = NULL) noexcept override;
301 bool logFormatted(const
char * i_format, ...) noexcept override;
309 const chrono::system_clock::time_point & i_msgTime, const
char * i_msg, const
char * i_extra =
nullptr
314 bool i_isToStamped, const chrono::system_clock::time_point & i_msgTime, const
char * i_msg, const
char * i_extra =
nullptr
Log base class: log to console and into log files.
Definition log.h:35
bool doLogMsg(const char *i_msg, const char *i_extra) noexcept
implement log message: log to console and log files
Definition log.cpp:198
const bool isEnabled(void) noexcept override
return true if log to console or to file enabled.
Definition log.cpp:174
~LogBase(void) noexcept
cleanup log resources
Definition log.cpp:76
const bool isCreateError(void) noexcept override
error at file create of last log or stamped log file
Definition log.cpp:186
const string timeStamp(void) noexcept override
return timestamp part of log file name: 2012_08_17_16_04_59_148.
Definition log.cpp:162
void setRank(int i_rank, int i_worldSize) noexcept override
use process rank as log message prefix
Definition log.cpp:138
log implementation class: log to console and into log files.
Definition log.h:150
const unordered_map< string, string > getLanguageMessages(void) noexcept override
get copy of language-specific messages
Definition log.cpp:396
~Log(void) noexcept
cleanup log resources
Definition log.cpp:302
const list< string > getLanguages(void) noexcept override
get list of language name for the messages, eg: (en-ca, en)
Definition log.cpp:383
bool logFormatted(const char *i_format,...) noexcept override
log message formatted with vsnprintf(), return false on error
Definition log.cpp:442
const string getMessage(const char *i_sourceMsg) noexcept override
get language-specific message by source non-translated message
Definition log.cpp:365
const string lastLogPath(void) noexcept override
if log to file enabled return "last" log file path.
Definition log.cpp:341
void logSql(const char *i_sql) noexcept override
log sql query
Definition log.cpp:478
void logErr(const exception &i_ex, const char *i_msg=nullptr) noexcept override
log exception
Definition log.cpp:469
const string stampedLogPath(void) noexcept override
if log to "stamped" file enabled return "stamped" log file path.
Definition log.cpp:353
void swapLanguageMessages(const list< string > &i_langLst, unordered_map< string, string > &io_msgMap) noexcept override
set language-specific messages and update list of languages
Definition log.cpp:409
void logMsg(const char *i_msg, const char *i_extra=NULL) noexcept override
log message
Definition log.cpp:420
trace log implementation class: model event log to console and into log files.
Definition log.h:255
~TraceLog(void) noexcept
cleanup trace log resources
Definition log.cpp:536
bool logFormatted(const char *i_format,...) noexcept override
log message formatted with vsnprintf(), return false on error
Definition log.cpp:583
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.
Definition log.h:267
void logMsg(const char *i_msg, const char *i_extra=NULL) noexcept override
log message
Definition log.cpp:574
OpenM++ common helper utilities.
openM++ namespace
Definition log.h:32
OpenM++: public interface for errors and exceptions.
OpenM++ common helper utilities.
OpenM++: public interface for log and trace support.
base for log public interface
Definition omLog.h:20
log public interface: log to console and into log files
Definition omLog.h:47
trace log public interface: model event log to console and into log files
Definition omLog.h:96