Kea 2.7.8
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
75 LoggerImpl(const std::string& name);
76
77
79 virtual ~LoggerImpl();
80
81
83 static std::string getVersion();
84
85
87 virtual std::string getName() {
88 return (name_);
89 }
90
91
101 virtual void setSeverity(Severity severity, int dbglevel = 1);
102
103
108 virtual Severity getSeverity();
109
110
117
118
123 virtual int getDebugLevel();
124
125
130 virtual int getEffectiveDebugLevel();
131
132
138 virtual bool isDebugEnabled(int dbglevel = MIN_DEBUG_LEVEL) {
139 Level level(DEBUG, dbglevel);
140 return logger_.isEnabledFor(LoggerLevelImpl::convertFromBindLevel(level));
141 }
142
144 virtual bool isInfoEnabled() {
145 return (logger_.isEnabledFor(log4cplus::INFO_LOG_LEVEL));
146 }
147
149 virtual bool isWarnEnabled() {
150 return (logger_.isEnabledFor(log4cplus::WARN_LOG_LEVEL));
151 }
152
154 virtual bool isErrorEnabled() {
155 return (logger_.isEnabledFor(log4cplus::ERROR_LOG_LEVEL));
156 }
157
159 virtual bool isFatalEnabled() {
160 return (logger_.isEnabledFor(log4cplus::FATAL_LOG_LEVEL));
161 }
162
171 void outputRaw(const Severity& severity, const std::string& message);
172
176 boost::shared_ptr<std::string> lookupMessage(const MessageID& id);
177
188
194 bool hasAppender(OutputOption::Destination const destination);
195
202 bool operator==(const LoggerImpl& other) const {
203 return (name_ == other.name_);
204 }
205
206private:
207 std::string name_;
208 log4cplus::Logger logger_;
210};
211
212} // namespace log
213} // namespace isc
214
215
216#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:87
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.