29 #ifdef TERRALIB_LOGGER_ENABLED
32 #include "Exception.h"
40 #include <boost/filesystem.hpp>
43 #ifdef TERRALIB_APACHE_LOG4CXX_ENABLED
44 #include <log4cxx/basicconfigurator.h>
45 #include <log4cxx/consoleappender.h>
46 #include <log4cxx/logger.h>
47 #include <log4cxx/logmanager.h>
48 #include <log4cxx/patternlayout.h>
49 #include <log4cxx/propertyconfigurator.h>
50 #include <log4cxx/xml/domconfigurator.h>
53 void te::common::Logger::initialize(
const std::string& loggerName,
55 const std::string& fileName)
57 #ifdef TERRALIB_APACHE_LOG4CXX_ENABLED
66 log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger(loggerName));
69 throw Exception(
TE_TR(
"It was not possible to initialize the logger!"));
73 log4cxx::xml::DOMConfigurator::configure(fileName);
77 log4cxx::PropertyConfigurator::configure(fileName);
81 throw Exception(
TE_TR(
"Invalid logger configuration type!"));
86 void te::common::Logger::initialize(
const std::string& loggerName)
88 #ifdef TERRALIB_APACHE_LOG4CXX_ENABLED
91 log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger(loggerName));
94 throw Exception(
TE_TR(
"It was not possible to initialize the the logger!"));
98 void te::common::Logger::finalize(
const std::string& loggerName)
100 #ifdef TERRALIB_APACHE_LOG4CXX_ENABLED
101 if(loggerName.empty())
102 throw Exception(
TE_TR(
"The logger name is empty!"));
104 log4cxx::LoggerPtr logger = log4cxx::LogManager::exists(loggerName);
109 logger->removeAllAppenders();
113 void te::common::Logger::logFatal(
const char* logger,
const char* msg)
115 #ifdef TERRALIB_APACHE_LOG4CXX_ENABLED
116 log4cxx::LoggerPtr lo(log4cxx::Logger::getLogger(logger));
117 LOG4CXX_FATAL(lo, msg);
121 void te::common::Logger::logFatal(
const std::string& logger,
const std::string& msg)
123 logFatal(logger.c_str(), msg.c_str());
126 void te::common::Logger::logAssert(
const char* logger,
bool condition,
const char* msg)
128 #ifdef TERRALIB_APACHE_LOG4CXX_ENABLED
129 log4cxx::LoggerPtr lo(log4cxx::Logger::getLogger(logger));
130 LOG4CXX_ASSERT(lo, condition, msg);
134 void te::common::Logger::logError(
const char* logger,
const char* msg)
136 #if TE_USE_APACHE_LOG4CXX
137 log4cxx::LoggerPtr lo(log4cxx::Logger::getLogger(logger));
138 LOG4CXX_ERROR(lo, msg);
142 void te::common::Logger::logWarning(
const char* logger,
const char* msg)
144 #ifdef TERRALIB_APACHE_LOG4CXX_ENABLED
145 log4cxx::LoggerPtr lo(log4cxx::Logger::getLogger(logger));
146 LOG4CXX_WARN(lo, msg);
150 void te::common::Logger::logInfo(
const char* logger,
const char* msg)
152 #ifdef TERRALIB_APACHE_LOG4CXX_ENABLED
153 log4cxx::LoggerPtr lo(log4cxx::Logger::getLogger(logger));
154 LOG4CXX_INFO(lo, msg);
158 void te::common::Logger::logInfo(
const std::string& logger,
const std::string& msg)
160 logInfo(logger.c_str(), msg.c_str());
163 void te::common::Logger::logDebug(
const char* logger,
const char* msg)
165 #ifdef TERRALIB_APACHE_LOG4CXX_ENABLED
166 log4cxx::LoggerPtr lo(log4cxx::Logger::getLogger(logger));
167 LOG4CXX_DEBUG(lo, msg);
171 void te::common::Logger::logTrace(
const char* logger,
const char* msg)
173 #ifdef TERRALIB_APACHE_LOG4CXX_ENABLED
174 log4cxx::LoggerPtr lo(log4cxx::Logger::getLogger(logger));
175 LOG4CXX_TRACE(lo, msg);
179 void te::common::Logger::logTrace(
const std::string& logger,
const std::string& msg)
181 logTrace(logger.c_str(), msg.c_str());
184 #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.