Kea: logger_name.cc Source File

| Kea 1.5.0

logger_name.cc
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 #include <config.h>
8
9 #include <string>
10 #include <log/logger_name.h>
11
12 namespace isc {
13 namespace log {
14
15 namespace {
16
17 // Obtain the root logger name in a way that is safe for statically-initialized
18 // objects.
19
20 std::string&
21 getRootLoggerNameInternal() {
22 static std::string root_name;
23 return (root_name);
24 }
25
26 } // Anonymous namespace
27
28 void
29 setRootLoggerName(const std::string& name) {
30 getRootLoggerNameInternal() = name;
31 }
32
33 const std::string& getRootLoggerName() {
34 return (getRootLoggerNameInternal());
35 }
36
37 const std::string& getDefaultRootLoggerName() {
38 static std::string root_name("kea");
39 return (root_name);
40 }
41
42 std::string expandLoggerName(const std::string& name) {
43
44 // Are we the root logger, or does the logger name start with
45 // the string "<root_logger_name>.". If so, use a logger
46 // whose name is the one given.
47 if ((name == getRootLoggerName()) ||
48 (name.find(getRootLoggerName() + std::string(".")) == 0)) {
49 return (name);
50
51 }
52
53 // Anything else is assumed to be a sub-logger of the root logger.
54 return (getRootLoggerName() + "." + name);
55 }
56
57 } // namespace log
58 } // namespace isc
isc::log::getRootLoggerName
const std::string & getRootLoggerName()
Get root logger name.
Definition: logger_name.cc:33
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
isc::log::getDefaultRootLoggerName
const std::string & getDefaultRootLoggerName()
Returns the default ('kea') root logger name.
Definition: logger_name.cc:37
logger_name.h
isc::log::expandLoggerName
std::string expandLoggerName(const std::string &name)
Expand logger name.
Definition: logger_name.cc:42
isc::log::setRootLoggerName
void setRootLoggerName(const std::string &name)
Set root logger name.
Definition: logger_name.cc:29