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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
// Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#ifndef DHCPSRV_LOGGING_INFO_H
#define DHCPSRV_LOGGING_INFO_H
#include <log/logger_level.h>
#include <log/logger_specification.h>
#include <stdint.h>
#include <vector>
namespace isc {
namespace dhcp {
/// @brief Defines single logging destination
///
/// This structure is used to keep log4cplus configuration parameters.
struct LoggingDestination {
/// @brief defines logging destination output
///
/// Values accepted are: stdout, stderr, syslog, syslog:name.
/// Any other destination will be considered a file name.
std::string output_;
/// @brief Maximum number of log files in rotation
int maxver_;
/// @brief Maximum log file size
uint64_t maxsize_;
/// @brief Compares two objects for equality.
///
/// @param other Object to be compared with this object.
///
/// @return true if objects are equal, false otherwise.
bool equals(const LoggingDestination& other) const;
/// @brief Default constructor.
LoggingDestination()
: output_("stdout"), maxver_(1), maxsize_(204800) {
}
};
/// @brief structure that describes one logging entry
///
/// This is a structure that conveys one logger entry configuration.
/// The structure in JSON form has the following syntax:
/// {
/// "name": "*",
/// "output_options": [
/// {
/// "output": "/path/to/the/logfile.log",
/// "maxver": 8,
/// "maxsize": 204800
/// }
/// ],
/// "severity": "WARN",
/// "debuglevel": 99
/// },
struct LoggingInfo {
/// @brief logging name
std::string name_;
/// @brief describes logging severity
isc::log::Severity severity_;
/// @brief debuglevel (used when severity_ == DEBUG)
///
/// We use range 0(least verbose)..99(most verbose)
int debuglevel_;
/// @brief specific logging destinations
std::vector<LoggingDestination> destinations_;
/// @brief Default constructor.
LoggingInfo();
/// @brief Removes logging destinations.
void clearDestinations() {
destinations_.clear();
}
/// @brief Compares two objects for equality.
///
/// @param other An object to be compared with this object.
///
/// @return true if objects are equal, false otherwise.
bool equals(const LoggingInfo& other) const;
/// @brief Compares two objects for equality.
///
/// @param other An object to be compared with this object.
///
/// @return true if objects are equal, false otherwise.
bool operator==(const LoggingInfo& other) const {
return (equals(other));
}
/// @brief Compares two objects for inequality.
///
/// @param other An object to be compared with this object.
///
/// @return true if objects are not equal, false otherwise.
bool operator!=(const LoggingInfo& other) const {
return (!equals(other));
}
/// @brief Converts logger configuration to a spec.
isc::log::LoggerSpecification toSpec() const;
};
/// @brief storage for logging information in log4cplus format
typedef std::vector<isc::dhcp::LoggingInfo> LoggingInfoStorage;
}
}
#endif // DHCPSRV_LOGGING_INFO_H
|