Kea: logger_impl.h Source File

| Kea 3.0.2-git

logger_impl.h
Go to the documentation of this file.
1// Copyright (C) 2011-2025 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
26#include <log/logger_level_impl.h>
27#include <log/message_types.h>
28#include <log/interprocess/interprocess_sync.h>
29#include <log/output_option.h>
30
31namespace isc {
32namespace log {
33
58
59 class 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
116 virtual Severity getEffectiveSeverity();
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
187 void setInterprocessSync(isc::log::interprocess::InterprocessSync* sync);
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_;
209 isc::log::interprocess::InterprocessSync* sync_;
210};
211
212} // namespace log
213} // namespace isc
214
215
216#endif // LOGGER_IMPL_H
isc::log::LoggerImpl::outputRaw
void outputRaw(const Severity &severity, const std::string &message)
Raw output.
Definition logger_impl.cc:154
isc::log::LoggerImpl::getEffectiveDebugLevel
virtual int getEffectiveDebugLevel()
Return effective debug level.
Definition logger_impl.cc:127
isc::log::LoggerImpl::setSeverity
virtual void setSeverity(Severity severity, int dbglevel=1)
Set Severity Level for Logger.
Definition logger_impl.cc:97
isc::log::LoggerImpl::lookupMessage
boost::shared_ptr< std::string > lookupMessage(const MessageID &id)
Look up message text in dictionary.
Definition logger_impl.cc:135
isc::log::LoggerImpl::isWarnEnabled
virtual bool isWarnEnabled()
Is WARNING Enabled?
Definition logger_impl.h:149
isc::log::LoggerImpl::~LoggerImpl
virtual ~LoggerImpl()
Destructor.
Definition logger_impl.cc:82
isc::log::LoggerImpl::setInterprocessSync
void setInterprocessSync(isc::log::interprocess::InterprocessSync *sync)
Replace the interprocess synchronization object.
Definition logger_impl.cc:143
isc::log::LoggerImpl::getEffectiveSeverity
virtual Severity getEffectiveSeverity()
Get Effective Severity Level for Logger.
Definition logger_impl.cc:119
isc::log::LoggerImpl::LoggerImpl
LoggerImpl(const std::string &name)
Constructor.
Definition logger_impl.cc:69
isc::log::LoggerImpl::getDebugLevel
virtual int getDebugLevel()
Return debug level.
Definition logger_impl.cc:111
isc::log::LoggerImpl::isInfoEnabled
virtual bool isInfoEnabled()
Is INFO Enabled?
Definition logger_impl.h:144
isc::log::LoggerImpl::hasAppender
bool hasAppender(OutputOption::Destination const destination)
Check if this logger has an appender of the given type.
Definition logger_impl.cc:203
isc::log::LoggerImpl::getSeverity
virtual Severity getSeverity()
Get Severity Level for Logger.
Definition logger_impl.cc:104
isc::log::LoggerImpl::getName
virtual std::string getName()
Get the full name of the logger (including the root name).
Definition logger_impl.h:87
isc::log::LoggerImpl::getVersion
static std::string getVersion()
Version.
Definition logger_impl.cc:88
isc::log::LoggerImpl::isErrorEnabled
virtual bool isErrorEnabled()
Is ERROR Enabled?
Definition logger_impl.h:154
isc::log::LoggerImpl::isFatalEnabled
virtual bool isFatalEnabled()
Is FATAL Enabled?
Definition logger_impl.h:159
isc::log::LoggerImpl::operator==
bool operator==(const LoggerImpl &other) const
Equality.
Definition logger_impl.h:202
isc::log::LoggerImpl::isDebugEnabled
virtual bool isDebugEnabled(int dbglevel=MIN_DEBUG_LEVEL)
Returns if Debug Message Should Be Output.
Definition logger_impl.h:138
isc::log::LoggerLevelImpl::convertFromBindLevel
static log4cplus::LogLevel convertFromBindLevel(const isc::log::Level &level)
Convert Kea level to log4cplus logging level.
Definition logger_level_impl.cc:33
isc::log::interprocess::InterprocessSync
Interprocess Sync Class.
Definition interprocess_sync.h:38
interprocess_sync.h
logger_level_impl.h
message_types.h
isc::log
Definition buffer_appender_impl.cc:17
isc::log::MIN_DEBUG_LEVEL
const int MIN_DEBUG_LEVEL
Minimum/maximum debug levels.
Definition logger_level.h:35
isc::log::MessageID
const char * MessageID
Definition message_types.h:15
isc::log::Severity
Severity
Severity Levels.
Definition logger_level.h:23
isc::log::DEBUG
@ DEBUG
Definition logger_level.h:25
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
output_option.h
isc::log::Level
Log level structure.
Definition logger_level.h:42
isc::log::OutputOption::Destination
Destination
Destinations.
Definition output_option.h:48