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>
56 const char*
const env = getenv(
"KEA_LOCKFILE_DIR");
57 if (env && boost::iequals(
string(env),
string(
"none"))) {
89 std::ostringstream ver;
91 ver << log4cplus::versionStr;
98 Level level(severity, dbglevel);
134boost::shared_ptr<string>
136 return (boost::make_shared<string>(
string(ident) +
" " +
146 "NULL was passed to setInterprocessSync()");
163 if (!locker.
lock()) {
164 LOG4CPLUS_ERROR(logger_,
"Unable to lock logger lockfile");
169 LOG4CPLUS_DEBUG(logger_, message);
173 LOG4CPLUS_INFO(logger_, message);
177 LOG4CPLUS_WARN(logger_, message);
181 LOG4CPLUS_ERROR(logger_, message);
185 LOG4CPLUS_FATAL(logger_, message);
192 LOG4CPLUS_ERROR(logger_,
193 "Unsupported severity in LoggerImpl::outputRaw(): "
198 LOG4CPLUS_ERROR(logger_,
"Unable to unlock logger lockfile");
205 log4cplus::SharedAppenderPtrList appenders(
206 log4cplus::Logger::getInstance(name_).getAllAppenders());
209 if (appenders.size() == 0) {
210 appenders = log4cplus::Logger::getInstance(
getRootLoggerName()).getAllAppenders();
213 for (
const log4cplus::helpers::SharedObjectPtr<log4cplus::Appender>& logger : appenders) {
215 dynamic_cast<log4cplus::ConsoleAppender*
>(logger.get())) {
218 dynamic_cast<log4cplus::FileAppender*
>(logger.get())) {
221 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.
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.