source: pacpusframework/trunk/include/Pacpus/kernel/Log.h@ 64

Last change on this file since 64 was 64, checked in by Marek Kurdej, 12 years ago

Modified property: added svn:keywords=Id.

  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1// This file is part of the PACPUS framework distributed under the
2// CECILL-C License, Version 1.0.
3//
4/// @author Marek Kurdej <firstname.surname@utc.fr>
5/// @date March, 2012
6/// @version $Id: Log.h 64 2013-01-09 16:41:12Z kurdejma $
7/// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
8/// @brief Logging facility.
9///
10/// Detailed description.
11
12#ifndef DEF_PACPUS_LOG_H
13#define DEF_PACPUS_LOG_H
14
15// Includes, pacpus.
16#include <Pacpus/kernel/pacpus.h>
17
18namespace pacpus {
19
20static class PACPUSLIB_API LogConfigurator
21{
22public:
23 LogConfigurator();
24 ~LogConfigurator();
25
26 static void configureLoggerWithFile(const char * configFilename);
27} initializer; // using Schwarz/nifty counter idiom for static initialization
28
29} // namespace pacpus
30
31#ifdef PACPUS_USE_LOG
32 // Includes, log4cxx.
33 #include <log4cxx/logger.h>
34
35 class QString;
36
37 /** Declare a log4cxx logger
38 * @param name Name of the logger, displayed when logging a message.
39 */
40 #define DECLARE_STATIC_LOGGER(name) \
41 static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger(name))
42
43 // Macros making logging user friendly.
44 #define LOG_TRACE(message) LOG4CXX_TRACE(logger, message)
45 #define LOG_DEBUG(message) LOG4CXX_DEBUG(logger, message)
46 #define LOG_INFO(message) LOG4CXX_INFO(logger, message)
47 #define LOG_WARN(message) LOG4CXX_WARN(logger, message)
48 #define LOG_ERROR(message) LOG4CXX_ERROR(logger, message)
49 #define LOG_FATAL(message) LOG4CXX_FATAL(logger, message)
50
51 // Provides helpers to log a QString.
52 PACPUSLIB_API ::log4cxx::helpers::CharMessageBuffer & operator<<(::log4cxx::helpers::CharMessageBuffer & os, const QString & s);
53 PACPUSLIB_API ::log4cxx::helpers::CharMessageBuffer & operator<<(::log4cxx::helpers::MessageBuffer & os, const QString & s);
54#else
55 #define DECLARE_STATIC_LOGGER(name)
56 #define LOG_TRACE(message)
57 #define LOG_DEBUG(message)
58 #define LOG_INFO(message)
59 #define LOG_WARN(message)
60 #define LOG_ERROR(message)
61 #define LOG_FATAL(message)
62#endif // PACPUS_USE_LOG
63
64#endif // DEF_PACPUS_LOG_H
Note: See TracBrowser for help on using the repository browser.