OpenM++ runtime library (libopenm)
omLog.h
Go to the documentation of this file.
1 
5 // Copyright (c) 2013-2015 OpenM++
6 // This code is licensed under the MIT license (see LICENSE.txt for details)
7 
8 #ifndef OM_H_LOG_H
9 #define OM_H_LOG_H
10 
11 #include <string>
12 #include <list>
13 #include <unordered_map>
14 
15 using namespace std;
16 
17 namespace openm
18 {
20  struct ILogBase
21  {
22  virtual ~ILogBase(void) noexcept = 0;
23 
25  virtual void logMsg(const char * i_msg, const char * i_extra = NULL) noexcept = 0;
26 
28  virtual void logFormatted(const char * i_format, ...) noexcept = 0;
29 
34  virtual const string timeStamp(void) noexcept = 0;
35  };
36 
38  struct ILog : public virtual ILogBase
39  {
40  virtual ~ILog(void) noexcept = 0;
41 
43  virtual void logErr(const exception & i_ex, const char * i_msg = NULL) noexcept = 0;
44 
46  virtual void logSql(const char * i_sql) noexcept = 0;
47 
57  virtual void init(
58  bool i_logToConsole,
59  const char * i_basePath,
60  bool i_logToFile,
61  bool i_useTimeStamp = false,
62  bool i_usePidStamp = false,
63  bool i_noMsgTime = false,
64  bool i_isLogSql = false
65  ) noexcept = 0;
66 
68  virtual const string lastLogPath(void) noexcept = 0;
69 
71  virtual const string stampedLogPath(void) noexcept = 0;
72 
74  virtual const string getMessage(const char * i_sourceMsg) noexcept = 0;
75 
77  virtual const list<string> getLanguages(void) noexcept = 0;
78 
80  virtual const unordered_map<string, string> getLanguageMessages(void) noexcept = 0;
81 
83  virtual void swapLanguageMessages(const list<string> & i_langLst, unordered_map<string, string> & io_msgMap) noexcept = 0;
84  };
85 
87  struct ITrace : public virtual ILogBase
88  {
89  virtual ~ITrace(void) noexcept = 0;
90 
100  virtual void init(
101  bool i_logToConsole,
102  const char * i_basePath,
103  bool i_logToFile,
104  bool i_useTimeStamp = false,
105  bool i_usePidStamp = false,
106  bool i_noMsgTime = false
107  ) noexcept = 0;
108  };
109 }
110 
111 //
112 // OpenM++ common library export
113 //
114 #ifdef __cplusplus
115  extern "C" {
116 #endif
117 
119 extern openm::ILog * theLog;
120 
122 extern openm::ITrace * theTrace;
123 
124 #ifdef __cplusplus
125  }
126 #endif
127 
129 #define LT(sourceMessage) ((theLog->getMessage(sourceMessage)).c_str())
130 
131 #endif // OM_H_LOG_H
openM++ namespace
Definition: argReader.cpp:16
base for log public interface
Definition: omLog.h:20
openm::ITrace * theTrace
trace log global instance: model debug output to console and log files
Definition: log.cpp:34
openm::ILog * theLog
log global instance: log to console and into log files
Definition: log.cpp:28
trace log public interface: model event log to console and into log files
Definition: omLog.h:87
log public interface: log to console and into log files
Definition: omLog.h:38