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

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

Fixed: using auto-generated PacpusLibConfig.h instead of pacpus.h.

  • Property svn:executable set to *
File size: 2.6 KB
Line 
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#include <Pacpus/kernel/PacpusLibConfig.h>
18
19namespace 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.
25static class PACPUSLIB_API LogConfigurator
26{
27public:
28 LogConfigurator();
29 ~LogConfigurator();
30 static void configureLoggerWithFile(const char * configFilename);
31} logInitializer;
32
33} // namespace pacpus
34
35#if defined(PACPUS_USE_LOG)
36# include <boost/log/attributes/named_scope.hpp>
37# include <boost/log/trivial.hpp>
38# include <iosfwd>
39
40class QString;
41template< typename CharT, typename TraitsT >
42PACPUSLIB_API std::basic_ostream< CharT, TraitsT >& operator<< (std::basic_ostream< CharT, TraitsT >& strm, QString const& s);
43
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
48#else
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
55
56/// Logs a message at TRACE level using default logger
57#define LOG_TRACE(message) PACPUS_LOG(trace, message)
58/// Logs a message at DEBUG level using default logger
59#define LOG_DEBUG(message) PACPUS_LOG(debug, message)
60/// Logs a message at INFO level using default logger
61#define LOG_INFO(message) PACPUS_LOG(info, message)
62/// Logs a message at WARN level using default logger
63#define LOG_WARN(message) PACPUS_LOG(warning, message)
64/// Logs a message at ERROR level using default logger
65#define LOG_ERROR(message) PACPUS_LOG(error, message)
66/// Logs a message at FATAL level using default logger
67#define LOG_FATAL(message) PACPUS_LOG(fatal, message)
68
69#endif // DEF_PACPUS_LOG_H
Note: See TracBrowser for help on using the repository browser.