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

Last change on this file since 351 was 237, checked in by Marek Kurdej, 11 years ago

Fixed: severity level output

  • Property svn:executable set to *
File size: 3.3 KB
RevLine 
[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
[236]19namespace pacpus
20{
[89]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.
26static class PACPUSLIB_API LogConfigurator
27{
28public:
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)
[236]37# include <boost/log/common.hpp>
[176]38# include <boost/log/attributes/named_scope.hpp>
[236]39# include <boost/log/core.hpp>
40# include <boost/log/sources/record_ostream.hpp>
41# include <boost/log/sources/severity_logger.hpp>
[237]42# include <boost/log/trivial.hpp>
[176]43# include <iosfwd>
[89]44
[236]45namespace pacpus
46{
47
[237]48 typedef boost::log::trivial::severity_level SeverityLevel;
49 using boost::log::trivial::trace;
50 using boost::log::trivial::debug;
51 using boost::log::trivial::info;
52 using boost::log::trivial::warning;
53 using boost::log::trivial::error;
54 using boost::log::trivial::fatal;
55
[236]56 BOOST_LOG_INLINE_GLOBAL_LOGGER_DEFAULT(gLogger, ::boost::log::sources::severity_logger_mt< ::pacpus::SeverityLevel>)
57
58} // namespace pacpus
59
[141]60class QString;
61template< typename CharT, typename TraitsT >
62PACPUSLIB_API std::basic_ostream< CharT, TraitsT >& operator<< (std::basic_ostream< CharT, TraitsT >& strm, QString const& s);
[89]63
[176]64# define DECLARE_STATIC_LOGGER(name) //BOOST_LOG_NAMED_SCOPE(name)
65# define PACPUS_LOG_FUNCTION() BOOST_LOG_FUNCTION()
66# define PACPUS_LOG_NAMED_SCOPE(name) BOOST_LOG_NAMED_SCOPE(name)
[236]67# define PACPUS_LOG(level, message) BOOST_LOG_SEV( ::pacpus::gLogger::get(), level) << message
[89]68#else
[176]69/// @param name Name of the logger, displayed when logging a message.
70# define DECLARE_STATIC_LOGGER(name)
71# define PACPUS_LOG_FUNCTION() ((void) 0)
72# define PACPUS_LOG_NAMED_SCOPE(name) ((void) 0)
73# define PACPUS_LOG(level, message) ((void) 0)
74#endif // PACPUS_USE_LOG
[141]75
76/// Logs a message at TRACE level using default logger
[236]77#define LOG_TRACE(message) PACPUS_LOG( ::pacpus::trace, message)
[141]78/// Logs a message at DEBUG level using default logger
[236]79#define LOG_DEBUG(message) PACPUS_LOG( ::pacpus::debug, message)
[141]80/// Logs a message at INFO level using default logger
[236]81#define LOG_INFO(message) PACPUS_LOG( ::pacpus::info, message)
[141]82/// Logs a message at WARN level using default logger
[236]83#define LOG_WARN(message) PACPUS_LOG( ::pacpus::warning, message)
[141]84/// Logs a message at ERROR level using default logger
[236]85#define LOG_ERROR(message) PACPUS_LOG( ::pacpus::error, message)
[141]86/// Logs a message at FATAL level using default logger
[236]87#define LOG_FATAL(message) PACPUS_LOG( ::pacpus::fatal, message)
[141]88
[89]89#endif // DEF_PACPUS_LOG_H
Note: See TracBrowser for help on using the repository browser.