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

Last change on this file since 55 was 31, checked in by sgosseli, 12 years ago

Huge commit: use the new includes style in all the files, add the license header in all the headers, and in some cpp.

File size: 2.0 KB
Line 
1/**
2 *
3 * Distributed under the UTC Heudiascy Pacpus License, Version 1.0.
4 * Copyright (c) UTC Heudiasyc 2010 - 2013. All rights reserved.
5 *
6 * See the LICENSE file for more information or a copy at:
7 * http://www.hds.utc.fr/~kurdejma/LICENSE_1_0.txt
8 *
9 */
10
11#ifndef DEF_PACPUS_LOG_H
12#define DEF_PACPUS_LOG_H
13
14// Includes, pacpus.
15#include <Pacpus/kernel/pacpus.h>
16
17namespace pacpus {
18
19static class PACPUSLIB_API LogConfigurator
20{
21public:
22 LogConfigurator();
23 ~LogConfigurator();
24
25 static void configureLoggerWithFile(const char * configFilename);
26} initializer; // using Schwarz/nifty counter idiom for static initialization
27
28} // namespace pacpus
29
30#ifdef PACPUS_USE_LOG
31 // Includes, log4cxx.
32 #include <log4cxx/logger.h>
33
34 class QString;
35
36 /** Declare a log4cxx logger
37 * @param name Name of the logger, displayed when logging a message.
38 */
39 #define DECLARE_STATIC_LOGGER(name) \
40 static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger(name))
41
42 // Macros making logging user friendly.
43 #define LOG_TRACE(message) LOG4CXX_TRACE(logger, message)
44 #define LOG_DEBUG(message) LOG4CXX_DEBUG(logger, message)
45 #define LOG_INFO(message) LOG4CXX_INFO(logger, message)
46 #define LOG_WARN(message) LOG4CXX_WARN(logger, message)
47 #define LOG_ERROR(message) LOG4CXX_ERROR(logger, message)
48 #define LOG_FATAL(message) LOG4CXX_FATAL(logger, message)
49
50 // Provides helpers to log a QString.
51 PACPUSLIB_API ::log4cxx::helpers::CharMessageBuffer & operator<<(::log4cxx::helpers::CharMessageBuffer & os, const QString & s);
52 PACPUSLIB_API ::log4cxx::helpers::CharMessageBuffer & operator<<(::log4cxx::helpers::MessageBuffer & os, const QString & s);
53#else
54 #define DECLARE_STATIC_LOGGER(name)
55 #define LOG_TRACE(message)
56 #define LOG_DEBUG(message)
57 #define LOG_INFO(message)
58 #define LOG_WARN(message)
59 #define LOG_ERROR(message)
60 #define LOG_FATAL(message)
61#endif // PACPUS_USE_LOG
62
63#endif // DEF_PACPUS_LOG_H
Note: See TracBrowser for help on using the repository browser.