Kea 2.7.5
logger_impl.h
Go to the documentation of this file.
1// Copyright (C) 2011-2022 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef LOGGER_IMPL_H
8#define LOGGER_IMPL_H
9
10#include <stdarg.h>
11#include <time.h>
12
13#include <iostream>
14#include <cstdlib>
15#include <string>
16#include <map>
17#include <utility>
18
19#include <boost/shared_ptr.hpp>
20#include <boost/noncopyable.hpp>
21
22// log4cplus logger header file
23#include <log4cplus/logger.h>
24
25// Kea logger files
27#include <log/message_types.h>
29#include <log/output_option.h>
30
31namespace isc {
32namespace log {
33
58
59class LoggerImpl : public boost::noncopyable {
60public:
61
67 LoggerImpl(const std::string& name);
68
69
71 virtual ~LoggerImpl();
72
73
75 static std::string getVersion();
76
77
79 virtual std::string getName() {
80 return (name_);
81 }
82
83
93 virtual void setSeverity(Severity severity, int dbglevel = 1);
94
95
100 virtual Severity getSeverity();
101
102
109
110
115 virtual int getDebugLevel();
116
117
122 virtual int getEffectiveDebugLevel();
123
124
130 virtual bool isDebugEnabled(int dbglevel = MIN_DEBUG_LEVEL) {
131 Level level(DEBUG, dbglevel);
132 return logger_.isEnabledFor(LoggerLevelImpl::convertFromBindLevel(level));
133 }
134
136 virtual bool isInfoEnabled() {
137 return (logger_.isEnabledFor(log4cplus::INFO_LOG_LEVEL));
138 }
139
141 virtual bool isWarnEnabled() {
142 return (logger_.isEnabledFor(log4cplus::WARN_LOG_LEVEL));
143 }
144
146 virtual bool isErrorEnabled() {
147 return (logger_.isEnabledFor(log4cplus::ERROR_LOG_LEVEL));
148 }
149
151 virtual bool isFatalEnabled() {
152 return (logger_.isEnabledFor(log4cplus::FATAL_LOG_LEVEL));
153 }
154
163 void outputRaw(const Severity& severity, const std::string& message);
164
168 boost::shared_ptr<std::string> lookupMessage(const MessageID& id);
169
180
186 bool hasAppender(OutputOption::Destination const destination);
187
194 bool operator==(const LoggerImpl& other) const {
195 return (name_ == other.name_);
196 }
197
198private:
199 std::string name_;
200 log4cplus::Logger logger_;
202};
203
204} // namespace log
205} // namespace isc
206
207
208#endif // LOGGER_IMPL_H
Console Logger Implementation.
Definition logger_impl.h:59
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 bool isWarnEnabled()
Is WARNING Enabled?
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.
virtual bool isInfoEnabled()
Is INFO Enabled?
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.
virtual std::string getName()
Get the full name of the logger (including the root name)
Definition logger_impl.h:79
static std::string getVersion()
Version.
virtual bool isErrorEnabled()
Is ERROR Enabled?
virtual bool isFatalEnabled()
Is FATAL Enabled?
bool operator==(const LoggerImpl &other) const
Equality.
virtual bool isDebugEnabled(int dbglevel=MIN_DEBUG_LEVEL)
Returns if Debug Message Should Be Output.
static log4cplus::LogLevel convertFromBindLevel(const isc::log::Level &level)
Convert Kea level to log4cplus logging level.
const int MIN_DEBUG_LEVEL
Minimum/maximum debug levels.
const char * MessageID
Severity
Severity Levels.
Defines the logger used by the top-level component of kea-lfc.
Log level structure.