30#ifndef __TERRALIB_CORE_LOGGER_LOGGER_H__ 
   31#define __TERRALIB_CORE_LOGGER_LOGGER_H__ 
   36#include "../utils/Platform.h" 
   39#include <boost/log/attributes/attribute_set.hpp> 
   40#include <boost/log/trivial.hpp> 
   42#if TE_PLATFORM == TE_PLATFORMCODE_MSWINDOWS 
   43  #define CURRENT_FUNCTION std::string(__FUNCTION__) 
   45  #define CURRENT_FUNCTION std::string(__PRETTY_FUNCTION__) 
  119        void addLogger(
const std::string &name, 
const std::string &filename, std::string format);
 
  169        std::pair< boost::log::attribute_set::iterator, bool > 
m_process;
 
  170        std::pair< boost::log::attribute_set::iterator, bool > 
m_processId;
 
  171        std::pair< boost::log::attribute_set::iterator, bool > 
m_threadId;
 
  186#ifdef TERRALIB_LOGGER_ENABLED 
  187  #define TE_ADD_LOGGER(name, filename, format) te::core::Logger::instance().addLogger(name, filename, format) 
  189  #define TE_ADD_LOGGER(name, filename, format) ((void)0) 
  202#ifdef TERRALIB_LOGGER_ENABLED 
  203  #define TE_ADD_LOGGER_FROM_FILE(filename) te::core::Logger::instance().addLoggerFromFile(filename) 
  205  #define TE_ADD_LOGGER_FROM_FILE(filename) ((void)0) 
  215#ifdef TERRALIB_LOGGER_ENABLED 
  216  #define TE_INIT_DEFAULT_LOGGER(filename) te::core::Logger::instance().addLogger(TERRALIB_DEFAULT_LOGGER, filename, TERRALIB_DEFAULT_LOGGER_FORMAT) 
  218  #define TE_INIT_DEFAULT_LOGGER(filename) ((void)0) 
  229#ifdef TERRALIB_LOGGER_TRACE_ENABLED 
  230  #define TE_CORE_LOG_TRACE(channel, message) te::core::Logger::instance().log(message, channel ,te::core::Logger::severity_level::trace) 
  232  #define TE_CORE_LOG_TRACE(channel, message) ((void)0) 
  243#ifdef TERRALIB_LOGGER_DEBUG_ENABLED 
  244  #define TE_CORE_LOG_DEBUG(channel, message) te::core::Logger::instance().log(message, channel ,te::core::Logger::severity_level::debug) 
  246  #define TE_CORE_LOG_DEBUG(channel, message) ((void)0) 
  257#ifdef TERRALIB_LOGGER_INFO_ENABLED 
  258  #define TE_CORE_LOG_INFO(channel, message) te::core::Logger::instance().log(message, channel ,te::core::Logger::severity_level::info) 
  260  #define TE_CORE_LOG_INFO(channel, message) ((void)0) 
  271#ifdef TERRALIB_LOGGER_WARN_ENABLED 
  272  #define TE_CORE_LOG_WARN(channel, message) te::core::Logger::instance().log(message, channel ,te::core::Logger::severity_level::warning) 
  274  #define TE_CORE_LOG_WARN(channel, message) ((void)0) 
  285#ifdef TERRALIB_LOGGER_ERROR_ENABLED 
  286  #define TE_CORE_LOG_ERROR(channel, message) te::core::Logger::instance().log(message, channel ,te::core::Logger::severity_level::error) 
  288  #define TE_CORE_LOG_ERROR(channel, message) ((void)0) 
  299#ifdef TERRALIB_LOGGER_FATAL_ENABLED 
  300  #define TE_CORE_LOG_FATAL(channel, message) te::core::Logger::instance().log(message, channel ,te::core::Logger::severity_level::fatal) 
  302  #define TE_CORE_LOG_FATAL(channel, message) ((void)0) 
  314#define TE_LOG_TRACE(message) TE_CORE_LOG_TRACE(TERRALIB_DEFAULT_LOGGER, CURRENT_FUNCTION + " : " + message)
 
  325#define TE_LOG_DEBUG(message) TE_CORE_LOG_DEBUG(TERRALIB_DEFAULT_LOGGER, CURRENT_FUNCTION + " : " + message)
 
  336#define TE_LOG_INFO(message) TE_CORE_LOG_INFO(TERRALIB_DEFAULT_LOGGER, CURRENT_FUNCTION + " : " + message)
 
  347#define TE_LOG_WARN(message)TE_CORE_LOG_WARN(TERRALIB_DEFAULT_LOGGER, CURRENT_FUNCTION + " : " + message)
 
  358#define TE_LOG_ERROR(message) TE_CORE_LOG_ERROR(TERRALIB_DEFAULT_LOGGER, CURRENT_FUNCTION + " : " + message)
 
  369#define TE_LOG_FATAL(message) TE_CORE_LOG_FATAL(TERRALIB_DEFAULT_LOGGER, CURRENT_FUNCTION + " : " + message)
 
  378#ifdef TERRALIB_LOGGER_ENABLED 
  379#define TE_SET_LOGGER_FILTER(severity) te::core::Logger::instance().setFilter(severity);  
  381#define TE_SET_LOGGER_FILTER(severity) ((void)0) 
const std::string TERRALIB_DEFAULT_LOGGER
The default name of the log file if none is informed.
 
const std::string TERRALIB_DEFAULT_LOGGER_FORMAT
The default message format if none is informed.
 
std::pair< boost::log::attribute_set::iterator, bool > m_threadId
 
~Logger()
Singleton destructor must be private or protected.
 
void addLogger(const std::string &name, const std::string &filename, std::string format)
It sets the logger using a default implementation.
 
void removeAllLoggers()
It removes all added loggers.
 
std::pair< boost::log::attribute_set::iterator, bool > m_processId
 
void setFilter(te::core::Logger::severity_level severity)
Sets the severity filter for the logger.
 
static Logger & instance()
It returns a reference to the singleton instance.
 
boost::log::trivial::severity_level toBoostSecurityLevel(te::core::Logger::severity_level severity)
Convert te::security_level to boost::security_level.
 
bool exists(const std::string &name)
Checks if exists a logger registered with the given name.
 
std::pair< boost::log::attribute_set::iterator, bool > m_process
 
void log(const std::string &message, const std::string &channel, severity_level severity)
It logs a given string message, channel and severity.
 
Logger()
Singleton constructor must be private or protected.
 
std::string getLoggingLevelName(te::core::Logger::severity_level severity)
Convert te::security_level to human readable name.
 
Logger & operator=(Logger const &)
Singleton copy assignment operator must be private or protected.
 
Logger(Logger const &)
Singleton copy constructor must be private or protected.
 
void addLoggerFromFile(const std::string &filename)
It sets the logger configuration from a given file.