Kea  1.9.9-git
logger_manager.h
Go to the documentation of this file.
1 // Copyright (C) 2011-2019 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>
12 
13 #include <boost/noncopyable.hpp>
14 
15 #include <mutex>
16 
17 // Generated if, when updating the logging specification, an unknown
18 // destination is encountered.
20 public:
21  UnknownLoggingDestination(const char* file, size_t line, const char* what) :
22  isc::Exception(file, line, what)
23  {}
24 };
25 
26 namespace isc {
27 namespace log {
28 
29 class LoggerManagerImpl;
30 
38 
39 class LoggerManager : public boost::noncopyable {
40 public:
42  LoggerManager();
43 
46 
55  template <typename T>
56  void process(T start, T finish) {
57  processInit();
58  for (T i = start; i != finish; ++i) {
59  processSpecification(*i);
60  }
61  processEnd();
62  }
63 
69  void process(const LoggerSpecification& spec) {
70  processInit();
71  processSpecification(spec);
72  processEnd();
73  }
74 
85  void process() {
86  processInit();
87  processEnd();
88  }
89 
111  static void init(const std::string& root,
113  int dbglevel = 0, const char* file = NULL,
114  bool buffer = false);
115 
122  static void logDuplicatedMessages();
123 
128  static void reset();
129 
137  static void readLocalMessageFile(const char* file);
138 
142  static std::mutex& getMutex();
143 
144 private:
151  void processInit();
152 
157  void processSpecification(const LoggerSpecification& spec);
158 
163  void processEnd();
164 
165  // Members
166  LoggerManagerImpl* impl_;
167 };
168 
169 } // namespace log
170 } // namespace isc
171 
172 
173 #endif // LOGGER_MANAGER_H
static void logDuplicatedMessages()
List duplicated log messages.
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.
void process(const LoggerSpecification &spec)
Process a single specification.
Logger Manager Implementation.
void process(T start, T finish)
Process Specifications.
void process()
Process 'empty' specification.
~LoggerManager()
Destructor.
Logger Manager.
static std::mutex & getMutex()
Return a process-global mutex that's used for mutual exclusion among threads of a single process duri...
static void reset()
Reset logging.
static void readLocalMessageFile(const char *file)
Read local message file.
Severity
Severity Levels.
Definition: logger_level.h:23
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
LoggerManager()
Constructor.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.
UnknownLoggingDestination(const char *file, size_t line, const char *what)