1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111 | // Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef LOGGER_UNITTEST_SUPPORT_H
#define LOGGER_UNITTEST_SUPPORT_H
#include <string><--- Include file: not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <log/logger.h>
/// \file
/// \brief Miscellaneous logging functions used by the unit tests.
///
/// As the configuration database is usually unavailable during unit tests,
/// the functions defined here allow a limited amount of logging configuration
/// through the use of environment variables
namespace isc {
namespace log {
/// \brief Run-Time Initialization for Unit Tests from Environment
///
/// Performs run-time initialization of the logger via the setting of
/// environment variables. These are:
///
/// - KEA_LOGGER_ROOT\n
/// Name of the root logger. If not given, the string "kea" will be used.
///
/// - KEA_LOGGER_SEVERITY\n
/// Severity of messages that will be logged. This must be one of the strings
/// "DEBUG", "INFO", "WARN", "ERROR", "FATAL" or "NONE". (Must be upper case
/// and must not contain leading or trailing spaces.) If not specified (or if
/// specified but incorrect), the default passed as argument to this function
/// (currently DEBUG) will be used.
///
/// - KEA_LOGGER_DBGLEVEL\n
/// Ignored if the level is not DEBUG, this should be a number between 0 and
/// 99 indicating the logging severity. The default is 0. If outside these
/// limits or if not a number, The value passed to this function (default
/// of MAX_DEBUG_LEVEL) is used.
///
/// - KEA_LOGGER_LOCALMSG\n
/// If defined, the path specification of a file that contains message
/// definitions replacing ones in the default dictionary.
///
/// - KEA_LOGGER_DESTINATION\n
/// If defined, the destination of the logging output. This can be one of:
/// - \c stdout Send output to stdout.
/// - \c stderr Send output to stderr
/// - \c syslog Send output to syslog using the facility local0.
/// - \c syslog:xxx Send output to syslog, using the facility xxx. ("xxx"
/// should be one of the syslog facilities such as "local0".) There must
/// be a colon between "syslog" and "xxx
/// - \c other Anything else is interpreted as the name of a file to which
/// output is appended. If the file does not exist, it is created.
///
/// Any errors in the settings cause messages to be output to stderr.
///
/// This function is aimed at test programs, allowing the default settings to
/// be overridden by the tester. It is not intended for use in production
/// code.
///
/// @note: Do NOT use this function in production code as it creates
/// lockfile in the build dir. That's ok for tests, but not
/// ok for production code.
///
/// @todo: Rename. This function overloads the initLogger() function that can
/// be used to initialize production programs. This may lead to confusion.
void initLogger(isc::log::Severity severity = isc::log::DEBUG,
int dbglevel = isc::log::MAX_DEBUG_LEVEL);
/// \brief Obtains logging severity from KEA_LOGGER_SEVERITY
///
/// Support function called by the unit test logging initialization code.
/// It returns the logging severity defined by KEA_LOGGER_SEVERITY. If
/// not defined it returns the default passed to it.
///
/// \param defseverity Default severity used if KEA_LOGGER_SEVERITY is not
// defined.
///
/// \return Severity to use for the logging.
isc::log::Severity keaLoggerSeverity(isc::log::Severity defseverity);
/// \brief Obtains logging debug level from KEA_LOGGER_DBGLEVEL
///
/// Support function called by the unit test logging initialization code.
/// It returns the logging debug level defined by KEA_LOGGER_DBGLEVEL. If
/// not defined, it returns the default passed to it.
///
/// N.B. If there is an error, a message is written to stderr and a value
/// related to the error is used. (This is because (a) logging is not yet
/// initialized, hence only the error stream is known to exist, and (b) this
/// function is only used in unit test logging initialization, so incorrect
/// selection of a level is not really an issue.)
///
/// \param defdbglevel Default debug level to be used if KEA_LOGGER_DBGLEVEL
/// is not defined.
///
/// \return Debug level to use.
int keaLoggerDbglevel(int defdbglevel);
} // namespace log
} // namespace isc
#endif // LOGGER_UNITTEST_SUPPORT_H
|