Kea  1.5.0
logger_manager.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_MANAGER_H
8 #define LOGGER_MANAGER_H
9 
10 #include <exceptions/exceptions.h>
11 #include <util/threads/sync.h>
13 
14 #include <boost/noncopyable.hpp>
15 
16 // Generated if, when updating the logging specification, an unknown
17 // destination is encountered.
19 public:
20  UnknownLoggingDestination(const char* file, size_t line, const char* what) :
21  isc::Exception(file, line, what)
22  {}
23 };
24 
25 namespace isc {
26 namespace log {
27 
28 class LoggerManagerImpl;
29 
37 
38 class LoggerManager : public boost::noncopyable {
39 public:
41  LoggerManager();
42 
45 
54  template <typename T>
55  void process(T start, T finish) {
56  processInit();
57  for (T i = start; i != finish; ++i) {
58  processSpecification(*i);
59  }
60  processEnd();
61  }
62 
68  void process(const LoggerSpecification& spec) {
69  processInit();
70  processSpecification(spec);
71  processEnd();
72  }
73 
84  void process() {
85  processInit();
86  processEnd();
87  }
88 
110  static void init(const std::string& root,
112  int dbglevel = 0, const char* file = NULL,
113  bool buffer = false);
114 
121  static void logDuplicatedMessages();
122 
127  static void reset();
128 
136  static void readLocalMessageFile(const char* file);
137 
142 
143 private:
150  void processInit();
151 
156  void processSpecification(const LoggerSpecification& spec);
157 
162  void processEnd();
163 
164  // Members
165  LoggerManagerImpl* impl_;
166 };
167 
168 } // namespace log
169 } // namespace isc
170 
171 
172 #endif // LOGGER_MANAGER_H
isc::log::LoggerManager::logDuplicatedMessages
static void logDuplicatedMessages()
List duplicated log messages.
Definition: logger_manager.cc:130
isc::log::LoggerManager::init
static void init(const std::string &root, isc::log::Severity severity=isc::log::INFO, int dbglevel=0, const char *file=NULL, bool buffer=false)
Run-Time Initialization.
Definition: logger_manager.cc:90
isc::log::LoggerManager::process
void process()
Process 'empty' specification.
Definition: logger_manager.h:84
isc::log::LoggerManager::~LoggerManager
~LoggerManager()
Destructor.
Definition: logger_manager.cc:64
sync.h
isc::log::LoggerSpecification
Definition: logger_specification.h:29
isc::log::Severity
Severity
Severity Levels.
Definition: logger_level.h:23
isc::util::thread::Mutex
Mutex with very simple interface.
Definition: sync.h:39
isc::Exception::Exception
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
Definition: exceptions/exceptions.cc:17
isc::Exception
This is a base class for exceptions thrown from the DNS library module.
Definition: exceptions/exceptions.h:23
isc::log::LoggerManager::readLocalMessageFile
static void readLocalMessageFile(const char *file)
Read local message file.
Definition: logger_manager.cc:150
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
isc::log::LoggerManager
Logger Manager.
Definition: logger_manager.h:38
isc::Exception::what
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Definition: exceptions/exceptions.cc:32
logger_specification.h
isc::log::LoggerManager::reset
static void reset()
Reset logging.
Definition: logger_manager.cc:193
isc::log::LoggerManager::getMutex
static isc::util::thread::Mutex & getMutex()
Return a process-global mutex that's used for mutual exclusion among threads of a single process duri...
Definition: logger_manager.cc:199
isc::log::LoggerManager::process
void process(const LoggerSpecification &spec)
Process a single specification.
Definition: logger_manager.h:68
isc::log::LoggerManager::process
void process(T start, T finish)
Process Specifications.
Definition: logger_manager.h:55
UnknownLoggingDestination::UnknownLoggingDestination
UnknownLoggingDestination(const char *file, size_t line, const char *what)
Definition: logger_manager.h:20
isc::log::LoggerManager::LoggerManager
LoggerManager()
Constructor.
Definition: logger_manager.cc:59
UnknownLoggingDestination
Definition: logger_manager.h:18
exceptions.h
isc::log::LoggerManagerImpl
Logger Manager Implementation.
Definition: logger_manager_impl.h:42
isc::log::INFO
@ INFO
Definition: logger_level.h:26