Kea 1.5.0
logger_impl.h
Go to the documentation of this file.
1// Copyright (C) 2011-2015 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#include <boost/noncopyable.hpp>
19
20
21// log4cplus logger header file
22#include <log4cplus/logger.h>
23
24// Kea logger files
26#include <log/message_types.h>
28
29namespace isc {
30namespace log {
31
56
57class LoggerImpl : public boost::noncopyable {
58public:
59
65 LoggerImpl(const std::string& name);
66
67
69 virtual ~LoggerImpl();
70
71
73 static std::string getVersion();
74
75
77 virtual std::string getName() {
78 return (name_);
79 }
80
81
91 virtual void setSeverity(Severity severity, int dbglevel = 1);
92
93
98 virtual Severity getSeverity();
99
100
107
108
113 virtual int getDebugLevel();
114
115
120 virtual int getEffectiveDebugLevel();
121
122
128 virtual bool isDebugEnabled(int dbglevel = MIN_DEBUG_LEVEL) {
129 Level level(DEBUG, dbglevel);
130 return logger_.isEnabledFor(LoggerLevelImpl::convertFromBindLevel(level));
131 }
132
134 virtual bool isInfoEnabled() {
135 return (logger_.isEnabledFor(log4cplus::INFO_LOG_LEVEL));
136 }
137
139 virtual bool isWarnEnabled() {
140 return (logger_.isEnabledFor(log4cplus::WARN_LOG_LEVEL));
141 }
142
144 virtual bool isErrorEnabled() {
145 return (logger_.isEnabledFor(log4cplus::ERROR_LOG_LEVEL));
146 }
147
149 virtual bool isFatalEnabled() {
150 return (logger_.isEnabledFor(log4cplus::FATAL_LOG_LEVEL));
151 }
152
161 void outputRaw(const Severity& severity, const std::string& message);
162
166 std::string* lookupMessage(const MessageID& id);
167
178
185 bool operator==(const LoggerImpl& other) {
186 return (name_ == other.name_);
187 }
188
189private:
190 std::string name_;
191 log4cplus::Logger logger_;
193};
194
195} // namespace log
196} // namespace isc
197
198
199#endif // LOGGER_IMPL_H
Console Logger Implementation.
Definition: logger_impl.h:57
bool operator==(const LoggerImpl &other)
Equality.
Definition: logger_impl.h:185
void outputRaw(const Severity &severity, const std::string &message)
Raw output.
Definition: logger_impl.cc:152
virtual int getEffectiveDebugLevel()
Return effective debug level.
Definition: logger_impl.cc:124
virtual void setSeverity(Severity severity, int dbglevel=1)
Set Severity Level for Logger.
Definition: logger_impl.cc:94
virtual bool isWarnEnabled()
Is WARNING Enabled?
Definition: logger_impl.h:139
virtual ~LoggerImpl()
Destructor.
Definition: logger_impl.cc:79
void setInterprocessSync(isc::log::interprocess::InterprocessSync *sync)
Replace the interprocess synchronization object.
Definition: logger_impl.cc:140
virtual Severity getEffectiveSeverity()
Get Effective Severity Level for Logger.
Definition: logger_impl.cc:116
virtual int getDebugLevel()
Return debug level.
Definition: logger_impl.cc:108
virtual bool isInfoEnabled()
Is INFO Enabled?
Definition: logger_impl.h:134
virtual Severity getSeverity()
Get Severity Level for Logger.
Definition: logger_impl.cc:101
virtual std::string getName()
Get the full name of the logger (including the root name)
Definition: logger_impl.h:77
static std::string getVersion()
Version.
Definition: logger_impl.cc:85
virtual bool isErrorEnabled()
Is ERROR Enabled?
Definition: logger_impl.h:144
virtual bool isFatalEnabled()
Is FATAL Enabled?
Definition: logger_impl.h:149
virtual bool isDebugEnabled(int dbglevel=MIN_DEBUG_LEVEL)
Returns if Debug Message Should Be Output.
Definition: logger_impl.h:128
std::string * lookupMessage(const MessageID &id)
Look up message text in dictionary.
Definition: logger_impl.cc:132
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.
Definition: logger_level.h:35
const char * MessageID
Definition: message_types.h:15
Severity
Severity Levels.
Definition: logger_level.h:23
Defines the logger used by the top-level component of kea-dhcp-ddns.
Log level structure.
Definition: logger_level.h:42