comparison Core/Logging.h @ 2483:9c54c40eaf25

logging primitives for WebAssembly
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 02 Mar 2018 15:10:37 +0100
parents 878b59270859
children 911e62dbb4ac
comparison
equal deleted inserted replaced
2482:509041cb57db 2483:9c54c40eaf25
45 # else 45 # else
46 # define ORTHANC_ENABLE_LOGGING_PLUGIN 0 46 # define ORTHANC_ENABLE_LOGGING_PLUGIN 0
47 # endif 47 # endif
48 #endif 48 #endif
49 49
50 #if !defined(ORTHANC_ENABLE_LOGGING_STDIO)
51 # if ORTHANC_ENABLE_LOGGING == 1
52 # error The macro ORTHANC_ENABLE_LOGGING_STDIO must be defined
53 # else
54 # define ORTHANC_ENABLE_LOGGING_STDIO 0
55 # endif
56 #endif
57
50 #if ORTHANC_ENABLE_LOGGING_PLUGIN == 1 58 #if ORTHANC_ENABLE_LOGGING_PLUGIN == 1
51 # include <orthanc/OrthancCPlugin.h> 59 # include <orthanc/OrthancCPlugin.h>
52 #endif 60 #endif
53 61
54 namespace Orthanc 62 namespace Orthanc
102 110
103 # define LOG(level) ::Orthanc::Logging::NullStream() 111 # define LOG(level) ::Orthanc::Logging::NullStream()
104 # define VLOG(level) ::Orthanc::Logging::NullStream() 112 # define VLOG(level) ::Orthanc::Logging::NullStream()
105 113
106 114
107 #elif ORTHANC_ENABLE_LOGGING_PLUGIN == 1 115 #elif (ORTHANC_ENABLE_LOGGING_PLUGIN == 1 || \
116 ORTHANC_ENABLE_LOGGING_STDIO == 1)
108 117
109 # include <boost/noncopyable.hpp> 118 # include <boost/noncopyable.hpp>
110 # define LOG(level) ::Orthanc::Logging::InternalLogger(#level, __FILE__, __LINE__) 119 # define LOG(level) ::Orthanc::Logging::InternalLogger \
111 # define VLOG(level) ::Orthanc::Logging::InternalLogger("TRACE", __FILE__, __LINE__) 120 (::Orthanc::Logging::level, __FILE__, __LINE__)
121 # define VLOG(level) ::Orthanc::Logging::InternalLogger \
122 (::Orthanc::Logging::TRACE, __FILE__, __LINE__)
112 123
113 namespace Orthanc 124 namespace Orthanc
114 { 125 {
115 namespace Logging 126 namespace Logging
116 { 127 {
128 enum Level
129 {
130 ERROR,
131 WARNING,
132 INFO,
133 TRACE
134 };
135
117 class InternalLogger : public boost::noncopyable 136 class InternalLogger : public boost::noncopyable
118 { 137 {
119 private: 138 private:
120 std::string level_; 139 Level level_;
121 std::string message_; 140 std::string message_;
122 141
123 public: 142 public:
124 InternalLogger(const char* level, 143 InternalLogger(Level level,
125 const char* file, 144 const char* file,
126 int line); 145 int line);
127 146
128 ~InternalLogger(); 147 ~InternalLogger();
129 148
135 }; 154 };
136 } 155 }
137 } 156 }
138 157
139 158
140 #else /* ORTHANC_ENABLE_LOGGING_PLUGIN == 0 && ORTHANC_ENABLE_LOGGING == 1 */ 159
160
161 #else /* ORTHANC_ENABLE_LOGGING_PLUGIN == 0 &&
162 ORTHANC_ENABLE_LOGGING_STDIO == 0 &&
163 ORTHANC_ENABLE_LOGGING == 1 */
141 164
142 # include <boost/thread/mutex.hpp> 165 # include <boost/thread/mutex.hpp>
143 # define LOG(level) ::Orthanc::Logging::InternalLogger(#level, __FILE__, __LINE__) 166 # define LOG(level) ::Orthanc::Logging::InternalLogger(#level, __FILE__, __LINE__)
144 # define VLOG(level) ::Orthanc::Logging::InternalLogger("TRACE", __FILE__, __LINE__) 167 # define VLOG(level) ::Orthanc::Logging::InternalLogger("TRACE", __FILE__, __LINE__)
145 168