28#pragma warning(disable : 4250)
49 const char * i_basePath,
61 const string timeStamp(
void)
noexcept override;
64 const bool isEnabled(
void)
noexcept override {
return isConsoleEnabled || isLastEnabled || isStampedEnabled; }
77 const char * i_basePath,
79 bool i_useTimeStamp =
false,
80 bool i_usePidStamp =
false,
81 bool i_noMsgTime =
false
85 void setRank(
int i_rank,
int i_worldSize) noexcept override;
88 recursive_mutex theMutex;
89 bool isConsoleEnabled;
92 bool isStampedEnabled;
93 bool isStampedCreated;
102 static const
size_t msgBufferSize = 32768;
103 char msgBuffer[msgBufferSize + 1];
108 void doLogMsg(const
char * i_msg, const
char * i_extra) noexcept;
111 bool logFileCreate(const
string & i_path) noexcept;
114 virtual
bool logToConsole(
115 const chrono::system_clock::time_point & i_msgTime, const
char * i_msg, const
char * i_extra =
nullptr
119 virtual
bool logToFile(
120 bool i_isToStamped, const chrono::system_clock::time_point & i_msgTime, const
char * i_msg, const
char * i_extra =
nullptr
125 ostream & i_ost, const chrono::system_clock::time_point & i_msgTime, const
char * i_msg, const
char * i_extra =
nullptr
157 bool i_logToConsole =
false,
158 const char * i_basePath =
"openm.log",
159 bool i_logToFile =
false,
160 bool i_useTimeStamp =
false,
161 bool i_usePidStamp =
false
178 const char * i_basePath,
180 bool i_useTimeStamp =
false,
181 bool i_usePidStamp =
false,
182 bool i_noMsgTime =
false,
183 bool i_isLogSql =
false
187 const string lastLogPath(
void)
noexcept override;
190 const string stampedLogPath(
void)
noexcept override;
193 const string getMessage(
const char * i_sourceMsg)
noexcept override;
196 const list<string> getLanguages(
void)
noexcept override;
199 const unordered_map<string, string> getLanguageMessages(
void)
noexcept override;
202 void swapLanguageMessages(
const list<string> & i_langLst, unordered_map<string, string> & io_msgMap)
noexcept override;
205 void logMsg(
const char * i_msg,
const char * i_extra = NULL)
noexcept override;
208 void logFormatted(
const char * i_format, ...)
noexcept override;
211 void logErr(
const exception & i_ex,
const char * i_msg =
nullptr)
noexcept override;
214 void logSql(
const char * i_sql)
noexcept override;
218 list<string> msgLangLst;
219 unordered_map<string, string> msgMap;
223 const chrono::system_clock::time_point & i_msgTime,
const char * i_msg,
const char * i_extra =
nullptr
228 bool i_isToStamped,
const chrono::system_clock::time_point & i_msgTime,
const char * i_msg,
const char * i_extra =
nullptr
232 Log(
const Log & i_log) =
delete;
233 Log & operator=(
const Log & i_log) =
delete;
263 bool i_logToConsole =
false,
264 const char * i_basePath =
"",
265 bool i_logToFile =
false,
266 bool i_useTimeStamp =
false,
267 bool i_usePidStamp =
false,
268 bool i_noMsgTime =
false
269 ) :
LogBase(i_logToConsole, i_basePath, i_logToFile, i_useTimeStamp, i_usePidStamp, i_noMsgTime)
285 const char * i_basePath,
287 bool i_useTimeStamp =
false,
288 bool i_usePidStamp =
false,
289 bool i_noMsgTime =
false
293 void logMsg(const
char * i_msg, const
char * i_extra = NULL) noexcept override;
296 void logFormatted(const
char * i_format, ...) noexcept override;
304 const chrono::system_clock::time_point & i_msgTime, const
char * i_msg, const
char * i_extra =
nullptr
309 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
void doLogMsg(const char *i_msg, const char *i_extra) noexcept
implement log message: log to console and log files
Definition: log.cpp:170
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.
Definition: log.cpp:92
~LogBase(void) noexcept
cleanup log resources
Definition: log.cpp:74
const bool isEnabled(void) noexcept override
return true if log to console or to file enabled.
Definition: log.h:64
LogBase(bool i_logToConsole, const char *i_basePath, bool i_logToFile, bool i_useTimeStamp, bool i_usePidStamp, bool i_noMsgTime)
create log instance.
Definition: log.cpp:51
const string timeStamp(void) noexcept override
return timestamp part of log file name: 2012_08_17_16_04_59_148.
Definition: log.cpp:158
void setRank(int i_rank, int i_worldSize) noexcept override
use process rank as log message prefix
Definition: log.cpp:134
log implementation class: log to console and into log files.
Definition: log.h:145
trace log implementation class: model event log to console and into log files.
Definition: log.h:250
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:262
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:19
virtual void logMsg(const char *i_msg, const char *i_extra=NULL) noexcept=0
log message
virtual void logFormatted(const char *i_format,...) noexcept=0
log message formatted with vsnprintf()
log public interface: log to console and into log files
Definition: omLog.h:43
trace log public interface: model event log to console and into log files
Definition: omLog.h:92