Kea 2.7.4
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
12namespace isc {
13namespace log {
14
15namespace {
16
17// Obtain the root logger name in a way that is safe for statically-initialized
18// objects.
19
20std::string&
21getRootLoggerNameInternal() {
22 static std::string root_name;
23 return (root_name);
24}
25
26} // Anonymous namespace
27
28void
29setRootLoggerName(const std::string& name) {
30 getRootLoggerNameInternal() = name;
31}
32
33const std::string& getRootLoggerName() {
34 return (getRootLoggerNameInternal());
35}
36
37const std::string& getDefaultRootLoggerName() {
38 static std::string root_name("kea");
39 return (root_name);
40}
41
42std::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
const std::string & getRootLoggerName()
Get root logger name.
std::string expandLoggerName(const std::string &name)
Expand logger name.
void setRootLoggerName(const std::string &name)
Set root logger name.
const std::string & getDefaultRootLoggerName()
Returns the default ('kea') root logger name.
Defines the logger used by the top-level component of kea-lfc.