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