18#include <boost/make_shared.hpp>
19#include <boost/lexical_cast.hpp>
20#include <boost/static_assert.hpp>
21#include <boost/algorithm/string.hpp>
23#include <log4cplus/configurator.h>
24#include <log4cplus/consoleappender.h>
25#include <log4cplus/fileappender.h>
26#include <log4cplus/loggingmacros.h>
27#include <log4cplus/syslogappender.h>
28#include <log4cplus/version.h>
58 const char*
const env = getenv(
"KEA_LOCKFILE_DIR");
59 if (env && boost::iequals(
string(env),
string(
"none"))) {
91 std::ostringstream ver;
93 ver << log4cplus::versionStr;
100 Level level(severity, dbglevel);
136boost::shared_ptr<string>
138 return (boost::make_shared<string>(
string(ident) +
" " +
148 "NULL was passed to setInterprocessSync()");
165 if (!locker.
lock()) {
166 LOG4CPLUS_ERROR(logger_,
"Unable to lock logger lockfile");
171 LOG4CPLUS_DEBUG(logger_, message);
175 LOG4CPLUS_INFO(logger_, message);
179 LOG4CPLUS_WARN(logger_, message);
183 LOG4CPLUS_ERROR(logger_, message);
187 LOG4CPLUS_FATAL(logger_, message);
194 LOG4CPLUS_ERROR(logger_,
195 "Unsupported severity in LoggerImpl::outputRaw(): "
200 LOG4CPLUS_ERROR(logger_,
"Unable to unlock logger lockfile");
207 log4cplus::SharedAppenderPtrList appenders(
208 log4cplus::Logger::getInstance(name_).getAllAppenders());
211 if (appenders.size() == 0) {
212 appenders = log4cplus::Logger::getInstance(
getRootLoggerName()).getAllAppenders();
215 for (log4cplus::helpers::SharedObjectPtr<log4cplus::Appender>
logger : appenders) {
217 dynamic_cast<log4cplus::ConsoleAppender*
>(
logger.get())) {
220 dynamic_cast<log4cplus::FileAppender*
>(
logger.get())) {
223 dynamic_cast<log4cplus::SysLogAppender*
>(
logger.get())) {
void outputRaw(const Severity &severity, const std::string &message)
Raw output.
virtual int getEffectiveDebugLevel()
Return effective debug level.
virtual void setSeverity(Severity severity, int dbglevel=1)
Set Severity Level for Logger.
boost::shared_ptr< std::string > lookupMessage(const MessageID &id)
Look up message text in dictionary.
virtual ~LoggerImpl()
Destructor.
void setInterprocessSync(isc::log::interprocess::InterprocessSync *sync)
Replace the interprocess synchronization object.
virtual Severity getEffectiveSeverity()
Get Effective Severity Level for Logger.
LoggerImpl(const std::string &name)
Constructor.
virtual int getDebugLevel()
Return debug level.
bool hasAppender(OutputOption::Destination const destination)
Check if this logger has an appender of the given type.
virtual Severity getSeverity()
Get Severity Level for Logger.
static std::string getVersion()
Version.
static log4cplus::LogLevel convertFromBindLevel(const isc::log::Level &level)
Convert Kea level to log4cplus logging level.
static isc::log::Level convertToBindLevel(const log4cplus::LogLevel loglevel)
Convert log4cplus logging level to Kea logging level.
static std::mutex & getMutex()
Return a process-global mutex that's used for mutual exclusion among threads of a single process duri...
static const MessageDictionaryPtr & globalDictionary()
Return Global Dictionary.
File-based Interprocess Sync Class.
Interprocess Sync Locker Class.
bool unlock()
Release the lock.
bool lock()
Acquire the lock (blocks if something else has acquired a lock on the same task name)
Null Interprocess Sync Class.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
isc::log::Logger logger("asiodns")
Use the ASIO logger.
const std::string & getRootLoggerName()
Get root logger name.
std::string expandLoggerName(const std::string &name)
Expand logger name.
bool lockfileEnabled()
detects whether file locking is enabled or disabled
Defines the logger used by the top-level component of kea-lfc.
Severity severity
Logging severity.