12#include <boost/lexical_cast.hpp>
14#include <log4cplus/logger.h>
36 static const log4cplus::LogLevel log4cplus_levels[] = {
37 log4cplus::NOT_SET_LOG_LEVEL,
38 log4cplus::DEBUG_LOG_LEVEL,
39 log4cplus::INFO_LOG_LEVEL,
40 log4cplus::WARN_LOG_LEVEL,
41 log4cplus::ERROR_LOG_LEVEL,
42 log4cplus::FATAL_LOG_LEVEL,
43 log4cplus::OFF_LOG_LEVEL
47 static_assert(
static_cast<int>(
DEFAULT) == 0,
48 "static_cast<int>(DEFAULT) == 0");
49 static_assert(
static_cast<int>(
DEBUG) == 1,
50 "static_cast<int>(DEBUG) == 1");
51 static_assert(
static_cast<int>(
INFO) == 2,
52 "static_cast<int>(INFO) == 2");
53 static_assert(
static_cast<int>(
WARN) == 3,
54 "static_cast<int>(WARN) == 3");
55 static_assert(
static_cast<int>(
ERROR) == 4,
56 "static_cast<int>(ERROR) == 4");
57 static_assert(
static_cast<int>(
FATAL) == 5,
58 "static_cast<int>(FATAL) == 5");
59 static_assert(
static_cast<int>(
NONE) == 6,
60 "static_cast<int>(NONE) == 6");
71 LogLevel newlevel =
static_cast<int>(DEBUG_LOG_LEVEL -
73 return (
static_cast<log4cplus::LogLevel
>(newlevel));
81 return (log4cplus_levels[level.
severity]);
92 if (loglevel <= log4cplus::NOT_SET_LOG_LEVEL) {
95 }
else if (loglevel <= log4cplus::DEBUG_LOG_LEVEL) {
101 static_cast<int>(log4cplus::DEBUG_LOG_LEVEL) -
102 static_cast<int>(loglevel);
110 }
else if (loglevel <= log4cplus::INFO_LOG_LEVEL) {
113 }
else if (loglevel <= log4cplus::WARN_LOG_LEVEL) {
116 }
else if (loglevel <= log4cplus::ERROR_LOG_LEVEL) {
119 }
else if (loglevel <= log4cplus::FATAL_LOG_LEVEL) {
132 std::string name = level;
133 size_t length = name.size();
139 return (NOT_SET_LOG_LEVEL);
141 if (strncasecmp(name.c_str(),
"DEBUG", 5) == 0) {
148 return (DEBUG_LOG_LEVEL);
157 int dbglevel = boost::lexical_cast<int>(name.substr(5));
171 catch (
const boost::bad_lexical_cast&) {
173 return (NOT_SET_LOG_LEVEL);
180 return (NOT_SET_LOG_LEVEL);
187#if LOG4CPLUS_VERSION < LOG4CPLUS_MAKE_VERSION(2, 0, 0)
199 if ((severity ==
DEBUG) &&
214 LogLevelManager& manager = getLogLevelManager();
static log4cplus::LogLevel convertFromBindLevel(const isc::log::Level &level)
Convert Kea level to log4cplus logging level.
static const LogLevelString & logLevelToString(log4cplus::LogLevel level)
Convert log level to string.
static log4cplus::LogLevel logLevelFromString(const log4cplus::tstring &level)
Convert string to log4cplus logging level.
log4cplus::tstring LogLevelString
static isc::log::Level convertToBindLevel(const log4cplus::LogLevel loglevel)
Convert log4cplus logging level to Kea logging level.
static void init()
Initialize extended logging levels.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
isc::log::Logger logger("asiodns")
Use the ASIO logger.
const isc::log::MessageID LOGIMPL_BAD_DEBUG_STRING
const isc::log::MessageID LOGIMPL_BELOW_MIN_DEBUG
const isc::log::MessageID LOGIMPL_ABOVE_MAX_DEBUG
const int MAX_DEBUG_LEVEL
const int MIN_DEBUG_LEVEL
Minimum/maximum debug levels.
Defines the logger used by the top-level component of kea-lfc.
Severity severity
Logging severity.