[89] | 1 | // %pacpus:license{
|
---|
| 2 | // This file is part of the PACPUS framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
| 4 | // %pacpus:license}
|
---|
| 5 | /// @file
|
---|
| 6 | /// @author Marek Kurdej <firstname.surname@utc.fr>
|
---|
| 7 | /// @date March, 2012
|
---|
| 8 | /// @version $Id: Log.h 73 2013-01-10 16:56:42Z kurdejma $
|
---|
| 9 | /// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
|
---|
| 10 | /// @brief Logging facility.
|
---|
| 11 | ///
|
---|
| 12 | /// Detailed description.
|
---|
| 13 |
|
---|
| 14 | #ifndef DEF_PACPUS_LOG_H
|
---|
| 15 | #define DEF_PACPUS_LOG_H
|
---|
| 16 |
|
---|
| 17 | // Includes, pacpus.
|
---|
| 18 | #include <Pacpus/kernel/pacpus.h>
|
---|
| 19 |
|
---|
| 20 | namespace pacpus {
|
---|
| 21 |
|
---|
| 22 | /// Static log facility initializer
|
---|
| 23 | ///
|
---|
| 24 | /// Uses Schwarz counter (nifty counter) idiom to initialize the log before
|
---|
| 25 | /// other static objects that could use the log.
|
---|
| 26 | static class PACPUSLIB_API LogConfigurator
|
---|
| 27 | {
|
---|
| 28 | public:
|
---|
| 29 | LogConfigurator();
|
---|
[143] | 30 | ~LogConfigurator();
|
---|
[89] | 31 | static void configureLoggerWithFile(const char * configFilename);
|
---|
[141] | 32 | } logInitializer;
|
---|
[89] | 33 |
|
---|
| 34 | } // namespace pacpus
|
---|
| 35 |
|
---|
[141] | 36 | #if defined(PACPUS_USE_LOG)
|
---|
[176] | 37 | # include <boost/log/attributes/named_scope.hpp>
|
---|
| 38 | # include <boost/log/trivial.hpp>
|
---|
| 39 | # include <iosfwd>
|
---|
[89] | 40 |
|
---|
[141] | 41 | class QString;
|
---|
| 42 | template< typename CharT, typename TraitsT >
|
---|
| 43 | PACPUSLIB_API std::basic_ostream< CharT, TraitsT >& operator<< (std::basic_ostream< CharT, TraitsT >& strm, QString const& s);
|
---|
[89] | 44 |
|
---|
[176] | 45 | # define DECLARE_STATIC_LOGGER(name) //BOOST_LOG_NAMED_SCOPE(name)
|
---|
| 46 | # define PACPUS_LOG_FUNCTION() BOOST_LOG_FUNCTION()
|
---|
| 47 | # define PACPUS_LOG_NAMED_SCOPE(name) BOOST_LOG_NAMED_SCOPE(name)
|
---|
| 48 | # define PACPUS_LOG(level, message) BOOST_LOG_TRIVIAL(level) << message
|
---|
[89] | 49 | #else
|
---|
[176] | 50 | /// @param name Name of the logger, displayed when logging a message.
|
---|
| 51 | # define DECLARE_STATIC_LOGGER(name)
|
---|
| 52 | # define PACPUS_LOG_FUNCTION() ((void) 0)
|
---|
| 53 | # define PACPUS_LOG_NAMED_SCOPE(name) ((void) 0)
|
---|
| 54 | # define PACPUS_LOG(level, message) ((void) 0)
|
---|
| 55 | #endif // PACPUS_USE_LOG
|
---|
[141] | 56 |
|
---|
| 57 | /// Logs a message at TRACE level using default logger
|
---|
[176] | 58 | #define LOG_TRACE(message) PACPUS_LOG(trace, message)
|
---|
[141] | 59 | /// Logs a message at DEBUG level using default logger
|
---|
[176] | 60 | #define LOG_DEBUG(message) PACPUS_LOG(debug, message)
|
---|
[141] | 61 | /// Logs a message at INFO level using default logger
|
---|
[176] | 62 | #define LOG_INFO(message) PACPUS_LOG(info, message)
|
---|
[141] | 63 | /// Logs a message at WARN level using default logger
|
---|
[176] | 64 | #define LOG_WARN(message) PACPUS_LOG(warning, message)
|
---|
[141] | 65 | /// Logs a message at ERROR level using default logger
|
---|
[176] | 66 | #define LOG_ERROR(message) PACPUS_LOG(error, message)
|
---|
[141] | 67 | /// Logs a message at FATAL level using default logger
|
---|
[176] | 68 | #define LOG_FATAL(message) PACPUS_LOG(fatal, message)
|
---|
[141] | 69 |
|
---|
[89] | 70 | #endif // DEF_PACPUS_LOG_H
|
---|