[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 |
|
---|
[196] | 17 | #include <Pacpus/kernel/PacpusLibConfig.h>
|
---|
[89] | 18 |
|
---|
| 19 | namespace pacpus {
|
---|
| 20 |
|
---|
| 21 | /// Static log facility initializer
|
---|
| 22 | ///
|
---|
| 23 | /// Uses Schwarz counter (nifty counter) idiom to initialize the log before
|
---|
| 24 | /// other static objects that could use the log.
|
---|
| 25 | static class PACPUSLIB_API LogConfigurator
|
---|
| 26 | {
|
---|
| 27 | public:
|
---|
| 28 | LogConfigurator();
|
---|
[143] | 29 | ~LogConfigurator();
|
---|
[89] | 30 | static void configureLoggerWithFile(const char * configFilename);
|
---|
[141] | 31 | } logInitializer;
|
---|
[89] | 32 |
|
---|
| 33 | } // namespace pacpus
|
---|
| 34 |
|
---|
[141] | 35 | #if defined(PACPUS_USE_LOG)
|
---|
[176] | 36 | # include <boost/log/attributes/named_scope.hpp>
|
---|
| 37 | # include <boost/log/trivial.hpp>
|
---|
| 38 | # include <iosfwd>
|
---|
[89] | 39 |
|
---|
[141] | 40 | class QString;
|
---|
| 41 | template< typename CharT, typename TraitsT >
|
---|
| 42 | PACPUSLIB_API std::basic_ostream< CharT, TraitsT >& operator<< (std::basic_ostream< CharT, TraitsT >& strm, QString const& s);
|
---|
[89] | 43 |
|
---|
[176] | 44 | # define DECLARE_STATIC_LOGGER(name) //BOOST_LOG_NAMED_SCOPE(name)
|
---|
| 45 | # define PACPUS_LOG_FUNCTION() BOOST_LOG_FUNCTION()
|
---|
| 46 | # define PACPUS_LOG_NAMED_SCOPE(name) BOOST_LOG_NAMED_SCOPE(name)
|
---|
| 47 | # define PACPUS_LOG(level, message) BOOST_LOG_TRIVIAL(level) << message
|
---|
[89] | 48 | #else
|
---|
[176] | 49 | /// @param name Name of the logger, displayed when logging a message.
|
---|
| 50 | # define DECLARE_STATIC_LOGGER(name)
|
---|
| 51 | # define PACPUS_LOG_FUNCTION() ((void) 0)
|
---|
| 52 | # define PACPUS_LOG_NAMED_SCOPE(name) ((void) 0)
|
---|
| 53 | # define PACPUS_LOG(level, message) ((void) 0)
|
---|
| 54 | #endif // PACPUS_USE_LOG
|
---|
[141] | 55 |
|
---|
| 56 | /// Logs a message at TRACE level using default logger
|
---|
[176] | 57 | #define LOG_TRACE(message) PACPUS_LOG(trace, message)
|
---|
[141] | 58 | /// Logs a message at DEBUG level using default logger
|
---|
[176] | 59 | #define LOG_DEBUG(message) PACPUS_LOG(debug, message)
|
---|
[141] | 60 | /// Logs a message at INFO level using default logger
|
---|
[176] | 61 | #define LOG_INFO(message) PACPUS_LOG(info, message)
|
---|
[141] | 62 | /// Logs a message at WARN level using default logger
|
---|
[176] | 63 | #define LOG_WARN(message) PACPUS_LOG(warning, message)
|
---|
[141] | 64 | /// Logs a message at ERROR level using default logger
|
---|
[176] | 65 | #define LOG_ERROR(message) PACPUS_LOG(error, message)
|
---|
[141] | 66 | /// Logs a message at FATAL level using default logger
|
---|
[176] | 67 | #define LOG_FATAL(message) PACPUS_LOG(fatal, message)
|
---|
[141] | 68 |
|
---|
[89] | 69 | #endif // DEF_PACPUS_LOG_H
|
---|