29 #ifdef TERRALIB_LOGGER_ENABLED
32 #include "Exception.h"
35 #include "terralib_config.h"
42 #include <boost/filesystem.hpp>
45 #ifdef TERRALIB_APACHE_LOG4CXX_ENABLED
46 #include <log4cxx/basicconfigurator.h>
47 #include <log4cxx/consoleappender.h>
48 #include <log4cxx/logger.h>
49 #include <log4cxx/logmanager.h>
50 #include <log4cxx/patternlayout.h>
51 #include <log4cxx/propertyconfigurator.h>
52 #include <log4cxx/xml/domconfigurator.h>
55 void te::common::Logger::initialize(
const std::string& loggerName,
57 const std::string& fileName)
59 #ifdef TERRALIB_APACHE_LOG4CXX_ENABLED
68 log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger(loggerName));
71 throw Exception(
TE_TR(
"It was not possible to initialize the logger!"));
75 log4cxx::xml::DOMConfigurator::configure(fileName);
79 log4cxx::PropertyConfigurator::configure(fileName);
83 throw Exception(
TE_TR(
"Invalid logger configuration type!"));
88 void te::common::Logger::initialize(
const std::string& loggerName)
90 #ifdef TERRALIB_APACHE_LOG4CXX_ENABLED
93 log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger(loggerName));
96 throw Exception(
TE_TR(
"It was not possible to initialize the the logger!"));
100 void te::common::Logger::finalize(
const std::string& loggerName)
102 #ifdef TERRALIB_APACHE_LOG4CXX_ENABLED
103 if(loggerName.empty())
104 throw Exception(
TE_TR(
"The logger name is empty!"));
106 log4cxx::LoggerPtr logger = log4cxx::LogManager::exists(loggerName);
111 logger->removeAllAppenders();
115 void te::common::Logger::logFatal(
const char* logger,
const char* msg)
117 #ifdef TERRALIB_APACHE_LOG4CXX_ENABLED
118 log4cxx::LoggerPtr lo(log4cxx::Logger::getLogger(logger));
119 LOG4CXX_FATAL(lo, msg);
123 void te::common::Logger::logFatal(
const std::string& logger,
const std::string& msg)
125 logFatal(logger.c_str(), msg.c_str());
128 void te::common::Logger::logAssert(
const char* logger,
bool condition,
const char* msg)
130 #ifdef TERRALIB_APACHE_LOG4CXX_ENABLED
131 log4cxx::LoggerPtr lo(log4cxx::Logger::getLogger(logger));
132 LOG4CXX_ASSERT(lo, condition, msg);
136 void te::common::Logger::logError(
const char* logger,
const char* msg)
138 #if TE_USE_APACHE_LOG4CXX
139 log4cxx::LoggerPtr lo(log4cxx::Logger::getLogger(logger));
140 LOG4CXX_ERROR(lo, msg);
144 void te::common::Logger::logWarning(
const char* logger,
const char* msg)
146 #ifdef TERRALIB_APACHE_LOG4CXX_ENABLED
147 log4cxx::LoggerPtr lo(log4cxx::Logger::getLogger(logger));
148 LOG4CXX_WARN(lo, msg);
152 void te::common::Logger::logInfo(
const char* logger,
const char* msg)
154 #ifdef TERRALIB_APACHE_LOG4CXX_ENABLED
155 log4cxx::LoggerPtr lo(log4cxx::Logger::getLogger(logger));
156 LOG4CXX_INFO(lo, msg);
160 void te::common::Logger::logInfo(
const std::string& logger,
const std::string& msg)
162 logInfo(logger.c_str(), msg.c_str());
165 void te::common::Logger::logDebug(
const char* logger,
const char* msg)
167 #ifdef TERRALIB_APACHE_LOG4CXX_ENABLED
168 log4cxx::LoggerPtr lo(log4cxx::Logger::getLogger(logger));
169 LOG4CXX_DEBUG(lo, msg);
173 void te::common::Logger::logTrace(
const char* logger,
const char* msg)
175 #ifdef TERRALIB_APACHE_LOG4CXX_ENABLED
176 log4cxx::LoggerPtr lo(log4cxx::Logger::getLogger(logger));
177 LOG4CXX_TRACE(lo, msg);
181 void te::common::Logger::logTrace(
const std::string& logger,
const std::string& msg)
183 logTrace(logger.c_str(), msg.c_str());
186 #endif // TERRALIB_LOGGER_ENABLED
#define TE_TR(message)
It marks a string in order to get translated.
LoggerConfigurationType
Each enumerated type tells TerraLib how the configuration is done for a logger.
This class is designed for dealing with multi-language text translation in TerraLib.
This class is designed to manage the log of information in TerraLib.