Changeset 236 in pacpusframework for trunk/include


Ignore:
Timestamp:
Nov 28, 2013, 5:07:16 PM (11 years ago)
Author:
Marek Kurdej
Message:

Experimental: using global logger object instead of trivial logger. Added: stub for colored log output on Linux.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/Pacpus/kernel/Log.h

    r196 r236  
    1717#include <Pacpus/kernel/PacpusLibConfig.h>
    1818
    19 namespace pacpus {
     19namespace pacpus
     20{
    2021
    2122/// Static log facility initializer
     
    3435
    3536#if defined(PACPUS_USE_LOG)
     37#   include <boost/log/common.hpp>
    3638#   include <boost/log/attributes/named_scope.hpp>
    37 #   include <boost/log/trivial.hpp>
     39#   include <boost/log/core.hpp>
     40#   include <boost/log/sources/record_ostream.hpp>
     41#   include <boost/log/sources/severity_logger.hpp>
    3842#   include <iosfwd>
     43
     44namespace pacpus
     45{
     46    /// Trivial severity levels
     47    /*PACPUSLIB_API*/ enum SeverityLevel
     48    {
     49        trace,
     50        debug,
     51        info,
     52        warning,
     53        error,
     54        fatal
     55    };
     56
     57    BOOST_LOG_INLINE_GLOBAL_LOGGER_DEFAULT(gLogger, ::boost::log::sources::severity_logger_mt< ::pacpus::SeverityLevel>)
     58
     59} // namespace pacpus
    3960
    4061class QString;
     
    4566#   define PACPUS_LOG_FUNCTION()              BOOST_LOG_FUNCTION()
    4667#   define PACPUS_LOG_NAMED_SCOPE(name)       BOOST_LOG_NAMED_SCOPE(name)
    47 #   define PACPUS_LOG(level, message)         BOOST_LOG_TRIVIAL(level) << message
     68#   define PACPUS_LOG(level, message)         BOOST_LOG_SEV( ::pacpus::gLogger::get(), level) << message
    4869#else
    4970/// @param name Name of the logger, displayed when logging a message.
     
    5576
    5677/// Logs a message at TRACE level using default logger
    57 #define LOG_TRACE(message)          PACPUS_LOG(trace, message)
     78#define LOG_TRACE(message)          PACPUS_LOG( ::pacpus::trace, message)
    5879/// Logs a message at DEBUG level using default logger
    59 #define LOG_DEBUG(message)          PACPUS_LOG(debug, message)
     80#define LOG_DEBUG(message)          PACPUS_LOG( ::pacpus::debug, message)
    6081/// Logs a message at INFO level using default logger
    61 #define LOG_INFO(message)           PACPUS_LOG(info, message)
     82#define LOG_INFO(message)           PACPUS_LOG( ::pacpus::info, message)
    6283/// Logs a message at WARN level using default logger
    63 #define LOG_WARN(message)           PACPUS_LOG(warning, message)
     84#define LOG_WARN(message)           PACPUS_LOG( ::pacpus::warning, message)
    6485/// Logs a message at ERROR level using default logger
    65 #define LOG_ERROR(message)          PACPUS_LOG(error, message)
     86#define LOG_ERROR(message)          PACPUS_LOG( ::pacpus::error, message)
    6687/// Logs a message at FATAL level using default logger
    67 #define LOG_FATAL(message)          PACPUS_LOG(fatal, message)
     88#define LOG_FATAL(message)          PACPUS_LOG( ::pacpus::fatal, message)
    6889
    6990#endif // DEF_PACPUS_LOG_H
Note: See TracChangeset for help on using the changeset viewer.