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

Last change on this file since 23 was 3, checked in by sgosseli, 12 years ago
  • Add the existing Pacpus files from pacpusdev and pacpuscore.
  • Provide a clean build system based on multiple CMake files.
File size: 1.9 KB
Line 
1// Copyright Marek Kurdej 2012.
2// Distributed under the UTC Heudiasyc Pacpus License, Version 1.0.
3// See accompanying file LICENSE_1_0.txt or copy at
4// http://www.hds.utc.fr/~kurdejma/LICENSE_1_0.txt
5
6#ifndef PACPUS_LOG_H
7#define PACPUS_LOG_H
8
9// Includes, pacpus.
10#include "pacpus.h"
11
12namespace pacpus {
13
14static class PACPUSLIB_API LogConfigurator
15{
16public:
17 LogConfigurator();
18 ~LogConfigurator();
19
20 static void configureLoggerWithFile(const char * configFilename);
21} initializer; // using Schwarz/nifty counter idiom for static initialization
22
23} // namespace pacpus
24
25#ifdef PACPUS_USE_LOG
26 // Includes, log4cxx.
27 #include <log4cxx/logger.h>
28
29 class QString;
30
31 /** Declare a log4cxx logger
32 * @param name Name of the logger, displayed when logging a message.
33 */
34 #define DECLARE_STATIC_LOGGER(name) \
35 static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger(name))
36
37 // Macros making logging user friendly.
38 #define LOG_TRACE(message) LOG4CXX_TRACE(logger, message)
39 #define LOG_DEBUG(message) LOG4CXX_DEBUG(logger, message)
40 #define LOG_INFO(message) LOG4CXX_INFO(logger, message)
41 #define LOG_WARN(message) LOG4CXX_WARN(logger, message)
42 #define LOG_ERROR(message) LOG4CXX_ERROR(logger, message)
43 #define LOG_FATAL(message) LOG4CXX_FATAL(logger, message)
44
45 // Provides helpers to log a QString.
46 PACPUSLIB_API ::log4cxx::helpers::CharMessageBuffer & operator<<(::log4cxx::helpers::CharMessageBuffer & os, const QString & s);
47 PACPUSLIB_API ::log4cxx::helpers::CharMessageBuffer & operator<<(::log4cxx::helpers::MessageBuffer & os, const QString & s);
48#else
49 #define DECLARE_STATIC_LOGGER(name)
50 #define LOG_TRACE(message)
51 #define LOG_DEBUG(message)
52 #define LOG_INFO(message)
53 #define LOG_WARN(message)
54 #define LOG_ERROR(message)
55 #define LOG_FATAL(message)
56#endif // PACPUS_USE_LOG
57
58#endif // PACPUS_LOG_H
Note: See TracBrowser for help on using the repository browser.