Kea  1.9.9-git
logger_impl.h
Go to the documentation of this file.
1 // Copyright (C) 2011-2020 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>
29 
30 namespace isc {
31 namespace log {
32 
57 
58 class LoggerImpl : public boost::noncopyable {
59 public:
60 
66  LoggerImpl(const std::string& name);
67 
68 
70  virtual ~LoggerImpl();
71 
72 
74  static std::string getVersion();
75 
76 
78  virtual std::string getName() {
79  return (name_);
80  }
81 
82 
92  virtual void setSeverity(Severity severity, int dbglevel = 1);
93 
94 
99  virtual Severity getSeverity();
100 
101 
107  virtual Severity getEffectiveSeverity();
108 
109 
114  virtual int getDebugLevel();
115 
116 
121  virtual int getEffectiveDebugLevel();
122 
123 
129  virtual bool isDebugEnabled(int dbglevel = MIN_DEBUG_LEVEL) {
130  Level level(DEBUG, dbglevel);
131  return logger_.isEnabledFor(LoggerLevelImpl::convertFromBindLevel(level));
132  }
133 
135  virtual bool isInfoEnabled() {
136  return (logger_.isEnabledFor(log4cplus::INFO_LOG_LEVEL));
137  }
138 
140  virtual bool isWarnEnabled() {
141  return (logger_.isEnabledFor(log4cplus::WARN_LOG_LEVEL));
142  }
143 
145  virtual bool isErrorEnabled() {
146  return (logger_.isEnabledFor(log4cplus::ERROR_LOG_LEVEL));
147  }
148 
150  virtual bool isFatalEnabled() {
151  return (logger_.isEnabledFor(log4cplus::FATAL_LOG_LEVEL));
152  }
153 
162  void outputRaw(const Severity& severity, const std::string& message);
163 
167  boost::shared_ptr<std::string> lookupMessage(const MessageID& id);
168 
179 
186  bool operator==(const LoggerImpl& other) {
187  return (name_ == other.name_);
188  }
189 
190 private:
191  std::string name_;
192  log4cplus::Logger logger_;
194 };
195 
196 } // namespace log
197 } // namespace isc
198 
199 
200 #endif // LOGGER_IMPL_H
virtual Severity getEffectiveSeverity()
Get Effective Severity Level for Logger.
Definition: logger_impl.cc:118
virtual bool isFatalEnabled()
Is FATAL Enabled?
Definition: logger_impl.h:150
virtual bool isInfoEnabled()
Is INFO Enabled?
Definition: logger_impl.h:135
virtual bool isErrorEnabled()
Is ERROR Enabled?
Definition: logger_impl.h:145
virtual std::string getName()
Get the full name of the logger (including the root name)
Definition: logger_impl.h:78
static log4cplus::LogLevel convertFromBindLevel(const isc::log::Level &level)
Convert Kea level to log4cplus logging level.
virtual bool isDebugEnabled(int dbglevel=MIN_DEBUG_LEVEL)
Returns if Debug Message Should Be Output.
Definition: logger_impl.h:129
virtual ~LoggerImpl()
Destructor.
Definition: logger_impl.cc:81
virtual bool isWarnEnabled()
Is WARNING Enabled?
Definition: logger_impl.h:140
const int MIN_DEBUG_LEVEL
Minimum/maximum debug levels.
Definition: logger_level.h:35
Console Logger Implementation.
Definition: logger_impl.h:58
Severity
Severity Levels.
Definition: logger_level.h:23
void setInterprocessSync(isc::log::interprocess::InterprocessSync *sync)
Replace the interprocess synchronization object.
Definition: logger_impl.cc:142
boost::shared_ptr< std::string > lookupMessage(const MessageID &id)
Look up message text in dictionary.
Definition: logger_impl.cc:134
Defines the logger used by the top-level component of kea-dhcp-ddns.
Log level structure.
Definition: logger_level.h:42
bool operator==(const LoggerImpl &other)
Equality.
Definition: logger_impl.h:186
static std::string getVersion()
Version.
Definition: logger_impl.cc:87
LoggerImpl(const std::string &name)
Constructor.
Definition: logger_impl.cc:68
virtual int getDebugLevel()
Return debug level.
Definition: logger_impl.cc:110
virtual void setSeverity(Severity severity, int dbglevel=1)
Set Severity Level for Logger.
Definition: logger_impl.cc:96
void outputRaw(const Severity &severity, const std::string &message)
Raw output.
Definition: logger_impl.cc:153
const char * MessageID
Definition: message_types.h:15
virtual Severity getSeverity()
Get Severity Level for Logger.
Definition: logger_impl.cc:103
virtual int getEffectiveDebugLevel()
Return effective debug level.
Definition: logger_impl.cc:126