Go to the documentation of this file.
30 #ifndef __TERRALIB_CORE_LOGGER_LOGGER_H__
31 #define __TERRALIB_CORE_LOGGER_LOGGER_H__
35 #include "../Config.h"
36 #include "../utils/Platform.h"
39 #include <boost/log/attributes/attribute_set.hpp>
41 #if TE_PLATFORM == TE_PLATFORMCODE_MSWINDOWS
42 #define CURRENT_FUNCTION std::string(__FUNCTION__)
44 #define CURRENT_FUNCTION std::string(__PRETTY_FUNCTION__)
117 void addLogger(
const std::string &name,
const std::string &filename, std::string format);
158 std::pair< boost::log::attribute_set::iterator, bool >
m_process;
159 std::pair< boost::log::attribute_set::iterator, bool >
m_processId;
160 std::pair< boost::log::attribute_set::iterator, bool >
m_threadId;
175 #ifdef TERRALIB_LOGGER_ENABLED
176 #define TE_ADD_LOGGER(name, filename, format) te::core::Logger::instance().addLogger(name, filename, format)
178 #define TE_ADD_LOGGER(name, filename, format) ((void)0)
191 #ifdef TERRALIB_LOGGER_ENABLED
192 #define TE_ADD_LOGGER_FROM_FILE(filename) te::core::Logger::instance().addLoggerFromFile(filename)
194 #define TE_ADD_LOGGER_FROM_FILE(filename) ((void)0)
204 #ifdef TERRALIB_LOGGER_ENABLED
205 #define TE_INIT_DEFAULT_LOGGER(filename) te::core::Logger::instance().addLogger(TERRALIB_DEFAULT_LOGGER, filename, TERRALIB_DEFAULT_LOGGER_FORMAT)
207 #define TE_INIT_DEFAULT_LOGGER(filename) ((void)0)
218 #ifdef TERRALIB_LOGGER_TRACE_ENABLED
219 #define TE_CORE_LOG_TRACE(channel, message) te::core::Logger::instance().log(message, channel ,te::core::Logger::severity_level::trace)
221 #define TE_CORE_LOG_TRACE(channel, message) ((void)0)
232 #ifdef TERRALIB_LOGGER_DEBUG_ENABLED
233 #define TE_CORE_LOG_DEBUG(channel, message) te::core::Logger::instance().log(message, channel ,te::core::Logger::severity_level::debug)
235 #define TE_CORE_LOG_DEBUG(channel, message) ((void)0)
246 #ifdef TERRALIB_LOGGER_INFO_ENABLED
247 #define TE_CORE_LOG_INFO(channel, message) te::core::Logger::instance().log(message, channel ,te::core::Logger::severity_level::info)
249 #define TE_CORE_LOG_INFO(channel, message) ((void)0)
260 #ifdef TERRALIB_LOGGER_WARN_ENABLED
261 #define TE_CORE_LOG_WARN(channel, message) te::core::Logger::instance().log(message, channel ,te::core::Logger::severity_level::warning)
263 #define TE_CORE_LOG_WARN(channel, message) ((void)0)
274 #ifdef TERRALIB_LOGGER_ERROR_ENABLED
275 #define TE_CORE_LOG_ERROR(channel, message) te::core::Logger::instance().log(message, channel ,te::core::Logger::severity_level::error)
277 #define TE_CORE_LOG_ERROR(channel, message) ((void)0)
288 #ifdef TERRALIB_LOGGER_FATAL_ENABLED
289 #define TE_CORE_LOG_FATAL(channel, message) te::core::Logger::instance().log(message, channel ,te::core::Logger::severity_level::fatal)
291 #define TE_CORE_LOG_FATAL(channel, message) ((void)0)
303 #define TE_LOG_TRACE(message) TE_CORE_LOG_TRACE(TERRALIB_DEFAULT_LOGGER, CURRENT_FUNCTION + " : " + message)
314 #define TE_LOG_DEBUG(message) TE_CORE_LOG_DEBUG(TERRALIB_DEFAULT_LOGGER, CURRENT_FUNCTION + " : " + message)
325 #define TE_LOG_INFO(message) TE_CORE_LOG_INFO(TERRALIB_DEFAULT_LOGGER, CURRENT_FUNCTION + " : " + message)
336 #define TE_LOG_WARN(message)TE_CORE_LOG_WARN(TERRALIB_DEFAULT_LOGGER, CURRENT_FUNCTION + " : " + message)
347 #define TE_LOG_ERROR(message) TE_CORE_LOG_ERROR(TERRALIB_DEFAULT_LOGGER, CURRENT_FUNCTION + " : " + message)
358 #define TE_LOG_FATAL(message) TE_CORE_LOG_FATAL(TERRALIB_DEFAULT_LOGGER, CURRENT_FUNCTION + " : " + message)
367 #ifdef TERRALIB_LOGGER_ENABLED
368 #define TE_SET_LOGGER_FILTER(severity) te::core::Logger::instance().setFilter(severity);
370 #define TE_SET_LOGGER_FILTER(severity) ((void)0)
373 #endif // __TERRALIB_CORE_LOGGER_LOGGER_H__
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.
Logger(Logger const &)
Singleton copy constructor must be private or protected.
std::pair< boost::log::attribute_set::iterator, bool > m_processId
static Logger & instance()
It returns a reference to the singleton instance.
bool exists(const std::string &name)
Checks if exists a logger registered with the given name.
~Logger()
Singleton destructor must be private or protected.
std::pair< boost::log::attribute_set::iterator, bool > m_process
void addLoggerFromFile(const std::string &filename)
It sets the logger configuration from a given file.
const std::string TERRALIB_DEFAULT_LOGGER
The default name of the log file if none is informed.
void removeAllLoggers()
It removes all added loggers.
void addLogger(const std::string &name, const std::string &filename, std::string format)
It sets the logger using a default implementation.
std::pair< boost::log::attribute_set::iterator, bool > m_threadId
const std::string TERRALIB_DEFAULT_LOGGER_FORMAT
The default message format if none is informed.
void setFilter(te::core::Logger::severity_level severity)
Sets the severity filter for the logger.
Logger & operator=(Logger const &)
Singleton copy assignment operator must be private or protected.