Computer Assited Medical Intervention Tool Kit  version 4.1
Log.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 #ifndef LOG_H
27 #define LOG_H
28 
29 // -- Core stuff
30 #include "CamiTKAPI.h"
31 #include "InterfaceLogger.h"
32 
33 namespace camitk {
34 
35 class InterfaceLogger;
36 
200 public:
204  static void setLogger(InterfaceLogger* logger);
205 
207  static InterfaceLogger* getLogger();
208 
210  static QString getLevelAsString(InterfaceLogger::LogLevel level);
211 
213  static InterfaceLogger::LogLevel getLevelFromString(QString levelString);
214 
215 private:
217 };
218 
219 // Generic log macro (it is NOT recommended to use it directly...)
220 #if !defined(CAMITK_DISABLE_LOG)
221 #define CAMITK_LOG(LEVEL,MSG,SENDER) camitk::Log::getLogger()->log(MSG, LEVEL, __FILE__, Q_FUNC_INFO, __LINE__, SENDER);
222 #define CAMITK_LOG_ALT(LEVEL,MSG) camitk::Log::getLogger()->log(MSG, LEVEL, __FILE__, __func__, __LINE__);
223 #else
224 #define CAMITK_LOG(LEVEL,MSG,SENDER)
225 #define CAMITK_LOG_ALT(LEVEL,MSG)
226 #endif
227 
230 #define CAMITK_TRACE(MSG) CAMITK_LOG(camitk::InterfaceLogger::TRACE, MSG, this)
231 #define CAMITK_TRACE_ALT(MSG) CAMITK_LOG_ALT(camitk::InterfaceLogger::TRACE, MSG)
232 
235 #define CAMITK_INFO(MSG) CAMITK_LOG(camitk::InterfaceLogger::INFO, MSG, this)
236 #define CAMITK_INFO_ALT(MSG) CAMITK_LOG_ALT(camitk::InterfaceLogger::INFO, MSG)
237 
240 #define CAMITK_WARNING(MSG) CAMITK_LOG(camitk::InterfaceLogger::WARNING, MSG, this)
241 #define CAMITK_WARNING_ALT(MSG) CAMITK_LOG_ALT(camitk::InterfaceLogger::WARNING, MSG)
242 
245 #ifdef ERROR
246 #define CAMITK_WINDOWS_SYSTEM_ERROR_SAFEGUARD ERROR
247 #undef ERROR
248 #endif
249 
250 #define CAMITK_ERROR(MSG) CAMITK_LOG(camitk::InterfaceLogger::ERROR, MSG, this)
251 #define CAMITK_ERROR_ALT(MSG) CAMITK_LOG_ALT(camitk::InterfaceLogger::ERROR, MSG)
252 
253 #ifdef CAMITK_WINDOWS_SYSTEM_ERROR_SAFEGUARD
254 #define ERROR CAMITK_WINDOWS_SYSTEM_ERROR_SAFEGUARD
255 #endif
256 
259 #define CAMITK_TRACE_IF(COND, MSG) \
260 { \
261  if (((COND))) { \
262  CAMITK_TRACE(MSG) \
263  } \
264 }
265 
266 #define CAMITK_TRACE_IF_ALT(COND, MSG) \
267 { \
268  if (((COND))) { \
269  CAMITK_TRACE_ALT(MSG) \
270  } \
271 }
272 
273 #define CAMITK_INFO_IF(COND, MSG) \
274 { \
275  if (((COND))) { \
276  CAMITK_INFO(MSG) \
277  } \
278 }
279 
280 #define CAMITK_INFO_IF_ALT(COND, MSG) \
281 { \
282  if (((COND))) { \
283  CAMITK_INFO_ALT(MSG) \
284  } \
285 }
286 
287 #define CAMITK_WARNING_IF(COND, MSG) \
288 { \
289  if (((COND))) { \
290  CAMITK_WARNING(MSG) \
291  } \
292 }
293 
294 #define CAMITK_WARNING_IF_ALT(COND, MSG) \
295 { \
296  if (((COND))) { \
297  CAMITK_WARNING_ALT(MSG) \
298  } \
299 }
300 
301 #define CAMITK_ERROR_IF(COND, MSG) \
302 { \
303  if (((COND))) { \
304  CAMITK_ERROR(MSG) \
305  } \
306 }
307 
308 #define CAMITK_ERROR_IF_ALT(COND, MSG) \
309 { \
310  if (((COND))) { \
311  CAMITK_ERROR_ALT(MSG) \
312  } \
313 }
314 
315 
316 }
317 
318 #endif // LOG_H
Definition: Action.cpp:36
static InterfaceLogger * applicationLogger
Global Logger manager.
Definition: Log.h:216
#define CAMITK_API
Definition: CamiTKAPI.h:49
LogLevel
: how chatty should the log output be...
Definition: InterfaceLogger.h:60
This class is a log utility.
Definition: Log.h:199
The CamiTK logger interface provides a flexible tracing system to CamiTK applications.
Definition: InterfaceLogger.h:51