Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
1822345b
Commit
1822345b
authored
Aug 29, 2014
by
Marcin Siodelski
Browse files
[3534] Logging information is accessed by getter.
parent
59cd21bb
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcpsrv/configuration.h
View file @
1822345b
...
...
@@ -110,9 +110,6 @@ public:
static
const
uint32_t
CFGSEL_ALL
=
0xFFFFFFFF
;
//@}
/// @brief logging specific information
LoggingInfoStorage
logging_info_
;
/// @brief Default constructor.
///
/// This constructor sets configuration sequence number to 0.
...
...
@@ -160,6 +157,18 @@ public:
/// @return true if sequence numbers are equal.
bool
sequenceEquals
(
const
Configuration
&
other
);
/// @brief Returns logging specific configuration.
const
LoggingInfoStorage
&
getLoggingInfo
()
const
{
return
(
logging_info_
);
}
/// @brief Sets logging specific configuration.
///
/// @param logging_info New logging configuration.
void
addLoggingInfo
(
const
LoggingInfo
&
logging_info
)
{
logging_info_
.
push_back
(
logging_info
);
}
/// @brief Returns object which represents selection of interfaces.
///
/// This function returns a reference to the object which represents the
...
...
@@ -182,6 +191,9 @@ private:
/// @brief Sequence number identifying the configuration.
uint32_t
sequence_
;
/// @brief Logging specific information.
LoggingInfoStorage
logging_info_
;
/// @brief Interface configuration.
///
/// Used to select interfaces on which the DHCP server will listen to
...
...
src/lib/dhcpsrv/logging.cc
View file @
1822345b
...
...
@@ -113,7 +113,7 @@ void LogConfigParser::parseConfigEntry(isc::data::ConstElementPtr entry) {
parseOutputOptions
(
info
.
destinations_
,
output_options
);
}
config_
->
l
ogging
_i
nfo
_
.
push_back
(
info
);
config_
->
addL
ogging
I
nfo
(
info
);
}
void
LogConfigParser
::
parseOutputOptions
(
std
::
vector
<
LoggingDestination
>&
destination
,
...
...
@@ -159,8 +159,9 @@ void LogConfigParser::applyConfiguration() {
std
::
vector
<
LoggerSpecification
>
specs
;
// Now iterate through all specified loggers
for
(
LoggingInfoStorage
::
const_iterator
it
=
config_
->
logging_info_
.
begin
();
it
!=
config_
->
logging_info_
.
end
();
++
it
)
{
const
LoggingInfoStorage
&
logging_info
=
config_
->
getLoggingInfo
();
for
(
LoggingInfoStorage
::
const_iterator
it
=
logging_info
.
begin
();
it
!=
logging_info
.
end
();
++
it
)
{
// Prepare the objects to define the logging specification
LoggerSpecification
spec
(
it
->
name_
,
...
...
src/lib/dhcpsrv/tests/cfgmgr_unittest.cc
View file @
1822345b
...
...
@@ -298,7 +298,7 @@ TEST_F(CfgMgrTest, configuration) {
ConfigurationPtr
configuration
=
CfgMgr
::
instance
().
getConfiguration
();
ASSERT_TRUE
(
configuration
);
EXPECT_TRUE
(
configuration
->
l
ogging
_i
nfo
_
.
empty
());
EXPECT_TRUE
(
configuration
->
getL
ogging
I
nfo
()
.
empty
());
}
// This test verifies that multiple option definitions can be added
...
...
src/lib/dhcpsrv/tests/configuration_unittest.cc
View file @
1822345b
...
...
@@ -159,7 +159,7 @@ ConfigurationTest::enableDDNS(const bool enable) {
// Check that by default there are no logging entries
TEST_F
(
ConfigurationTest
,
basic
)
{
EXPECT_TRUE
(
conf_
.
l
ogging
_i
nfo
_
.
empty
());
EXPECT_TRUE
(
conf_
.
getL
ogging
I
nfo
()
.
empty
());
}
// Check that Configuration can store logging information.
...
...
@@ -176,15 +176,15 @@ TEST_F(ConfigurationTest, loggingInfo) {
log1
.
destinations_
.
push_back
(
dest
);
conf_
.
l
ogging
_i
nfo
_
.
push_back
(
log1
);
conf_
.
addL
ogging
I
nfo
(
log1
);
EXPECT_EQ
(
"foo"
,
conf_
.
l
ogging
_i
nfo
_
[
0
].
name_
);
EXPECT_EQ
(
isc
::
log
::
WARN
,
conf_
.
l
ogging
_i
nfo
_
[
0
].
severity_
);
EXPECT_EQ
(
77
,
conf_
.
l
ogging
_i
nfo
_
[
0
].
debuglevel_
);
EXPECT_EQ
(
"foo"
,
conf_
.
getL
ogging
I
nfo
()
[
0
].
name_
);
EXPECT_EQ
(
isc
::
log
::
WARN
,
conf_
.
getL
ogging
I
nfo
()
[
0
].
severity_
);
EXPECT_EQ
(
77
,
conf_
.
getL
ogging
I
nfo
()
[
0
].
debuglevel_
);
EXPECT_EQ
(
"some-logfile.txt"
,
conf_
.
l
ogging
_i
nfo
_
[
0
].
destinations_
[
0
].
output_
);
EXPECT_EQ
(
5
,
conf_
.
l
ogging
_i
nfo
_
[
0
].
destinations_
[
0
].
maxver_
);
EXPECT_EQ
(
2097152
,
conf_
.
l
ogging
_i
nfo
_
[
0
].
destinations_
[
0
].
maxsize_
);
EXPECT_EQ
(
"some-logfile.txt"
,
conf_
.
getL
ogging
I
nfo
()
[
0
].
destinations_
[
0
].
output_
);
EXPECT_EQ
(
5
,
conf_
.
getL
ogging
I
nfo
()
[
0
].
destinations_
[
0
].
maxver_
);
EXPECT_EQ
(
2097152
,
conf_
.
getL
ogging
I
nfo
()
[
0
].
destinations_
[
0
].
maxsize_
);
}
// Check that the configuration summary including information about the status
...
...
src/lib/dhcpsrv/tests/daemon_unittest.cc
View file @
1822345b
...
...
@@ -73,14 +73,14 @@ TEST(DaemonTest, parsingConsoleOutput) {
// The parsed configuration should be processed by the daemon and
// stored in configuration storage.
ASSERT_EQ
(
1
,
storage
->
l
ogging
_i
nfo
_
.
size
());
ASSERT_EQ
(
1
,
storage
->
getL
ogging
I
nfo
()
.
size
());
EXPECT_EQ
(
"kea"
,
storage
->
l
ogging
_i
nfo
_
[
0
].
name_
);
EXPECT_EQ
(
99
,
storage
->
l
ogging
_i
nfo
_
[
0
].
debuglevel_
);
EXPECT_EQ
(
isc
::
log
::
DEBUG
,
storage
->
l
ogging
_i
nfo
_
[
0
].
severity_
);
EXPECT_EQ
(
"kea"
,
storage
->
getL
ogging
I
nfo
()
[
0
].
name_
);
EXPECT_EQ
(
99
,
storage
->
getL
ogging
I
nfo
()
[
0
].
debuglevel_
);
EXPECT_EQ
(
isc
::
log
::
DEBUG
,
storage
->
getL
ogging
I
nfo
()
[
0
].
severity_
);
ASSERT_EQ
(
1
,
storage
->
l
ogging
_i
nfo
_
[
0
].
destinations_
.
size
());
EXPECT_EQ
(
"stdout"
,
storage
->
l
ogging
_i
nfo
_
[
0
].
destinations_
[
0
].
output_
);
ASSERT_EQ
(
1
,
storage
->
getL
ogging
I
nfo
()
[
0
].
destinations_
.
size
());
EXPECT_EQ
(
"stdout"
,
storage
->
getL
ogging
I
nfo
()
[
0
].
destinations_
[
0
].
output_
);
}
...
...
src/lib/dhcpsrv/tests/logging_unittest.cc
View file @
1822345b
...
...
@@ -66,14 +66,14 @@ TEST(LoggingTest, parsingConsoleOutput) {
EXPECT_NO_THROW
(
parser
.
parseConfiguration
(
config
));
ASSERT_EQ
(
1
,
storage
->
l
ogging
_i
nfo
_
.
size
());
ASSERT_EQ
(
1
,
storage
->
getL
ogging
I
nfo
()
.
size
());
EXPECT_EQ
(
"kea"
,
storage
->
l
ogging
_i
nfo
_
[
0
].
name_
);
EXPECT_EQ
(
99
,
storage
->
l
ogging
_i
nfo
_
[
0
].
debuglevel_
);
EXPECT_EQ
(
isc
::
log
::
DEBUG
,
storage
->
l
ogging
_i
nfo
_
[
0
].
severity_
);
EXPECT_EQ
(
"kea"
,
storage
->
getL
ogging
I
nfo
()
[
0
].
name_
);
EXPECT_EQ
(
99
,
storage
->
getL
ogging
I
nfo
()
[
0
].
debuglevel_
);
EXPECT_EQ
(
isc
::
log
::
DEBUG
,
storage
->
getL
ogging
I
nfo
()
[
0
].
severity_
);
ASSERT_EQ
(
1
,
storage
->
l
ogging
_i
nfo
_
[
0
].
destinations_
.
size
());
EXPECT_EQ
(
"stdout"
,
storage
->
l
ogging
_i
nfo
_
[
0
].
destinations_
[
0
].
output_
);
ASSERT_EQ
(
1
,
storage
->
getL
ogging
I
nfo
()
[
0
].
destinations_
.
size
());
EXPECT_EQ
(
"stdout"
,
storage
->
getL
ogging
I
nfo
()
[
0
].
destinations_
[
0
].
output_
);
}
// Checks if the LogConfigParser class is able to transform JSON structures
...
...
@@ -106,14 +106,14 @@ TEST(LoggingTest, parsingFile) {
EXPECT_NO_THROW
(
parser
.
parseConfiguration
(
config
));
ASSERT_EQ
(
1
,
storage
->
l
ogging
_i
nfo
_
.
size
());
ASSERT_EQ
(
1
,
storage
->
getL
ogging
I
nfo
()
.
size
());
EXPECT_EQ
(
"kea"
,
storage
->
l
ogging
_i
nfo
_
[
0
].
name_
);
EXPECT_EQ
(
0
,
storage
->
l
ogging
_i
nfo
_
[
0
].
debuglevel_
);
EXPECT_EQ
(
isc
::
log
::
INFO
,
storage
->
l
ogging
_i
nfo
_
[
0
].
severity_
);
EXPECT_EQ
(
"kea"
,
storage
->
getL
ogging
I
nfo
()
[
0
].
name_
);
EXPECT_EQ
(
0
,
storage
->
getL
ogging
I
nfo
()
[
0
].
debuglevel_
);
EXPECT_EQ
(
isc
::
log
::
INFO
,
storage
->
getL
ogging
I
nfo
()
[
0
].
severity_
);
ASSERT_EQ
(
1
,
storage
->
l
ogging
_i
nfo
_
[
0
].
destinations_
.
size
());
EXPECT_EQ
(
"logfile.txt"
,
storage
->
l
ogging
_i
nfo
_
[
0
].
destinations_
[
0
].
output_
);
ASSERT_EQ
(
1
,
storage
->
getL
ogging
I
nfo
()
[
0
].
destinations_
.
size
());
EXPECT_EQ
(
"logfile.txt"
,
storage
->
getL
ogging
I
nfo
()
[
0
].
destinations_
[
0
].
output_
);
}
// Checks if the LogConfigParser class is able to transform data structures
...
...
@@ -156,19 +156,19 @@ TEST(LoggingTest, multipleLoggers) {
EXPECT_NO_THROW
(
parser
.
parseConfiguration
(
config
));
ASSERT_EQ
(
2
,
storage
->
l
ogging
_i
nfo
_
.
size
());
ASSERT_EQ
(
2
,
storage
->
getL
ogging
I
nfo
()
.
size
());
EXPECT_EQ
(
"kea"
,
storage
->
l
ogging
_i
nfo
_
[
0
].
name_
);
EXPECT_EQ
(
0
,
storage
->
l
ogging
_i
nfo
_
[
0
].
debuglevel_
);
EXPECT_EQ
(
isc
::
log
::
INFO
,
storage
->
l
ogging
_i
nfo
_
[
0
].
severity_
);
ASSERT_EQ
(
1
,
storage
->
l
ogging
_i
nfo
_
[
0
].
destinations_
.
size
());
EXPECT_EQ
(
"logfile.txt"
,
storage
->
l
ogging
_i
nfo
_
[
0
].
destinations_
[
0
].
output_
);
EXPECT_EQ
(
"kea"
,
storage
->
getL
ogging
I
nfo
()
[
0
].
name_
);
EXPECT_EQ
(
0
,
storage
->
getL
ogging
I
nfo
()
[
0
].
debuglevel_
);
EXPECT_EQ
(
isc
::
log
::
INFO
,
storage
->
getL
ogging
I
nfo
()
[
0
].
severity_
);
ASSERT_EQ
(
1
,
storage
->
getL
ogging
I
nfo
()
[
0
].
destinations_
.
size
());
EXPECT_EQ
(
"logfile.txt"
,
storage
->
getL
ogging
I
nfo
()
[
0
].
destinations_
[
0
].
output_
);
EXPECT_EQ
(
"wombat"
,
storage
->
l
ogging
_i
nfo
_
[
1
].
name_
);
EXPECT_EQ
(
99
,
storage
->
l
ogging
_i
nfo
_
[
1
].
debuglevel_
);
EXPECT_EQ
(
isc
::
log
::
DEBUG
,
storage
->
l
ogging
_i
nfo
_
[
1
].
severity_
);
ASSERT_EQ
(
1
,
storage
->
l
ogging
_i
nfo
_
[
1
].
destinations_
.
size
());
EXPECT_EQ
(
"logfile2.txt"
,
storage
->
l
ogging
_i
nfo
_
[
1
].
destinations_
[
0
].
output_
);
EXPECT_EQ
(
"wombat"
,
storage
->
getL
ogging
I
nfo
()
[
1
].
name_
);
EXPECT_EQ
(
99
,
storage
->
getL
ogging
I
nfo
()
[
1
].
debuglevel_
);
EXPECT_EQ
(
isc
::
log
::
DEBUG
,
storage
->
getL
ogging
I
nfo
()
[
1
].
severity_
);
ASSERT_EQ
(
1
,
storage
->
getL
ogging
I
nfo
()
[
1
].
destinations_
.
size
());
EXPECT_EQ
(
"logfile2.txt"
,
storage
->
getL
ogging
I
nfo
()
[
1
].
destinations_
[
0
].
output_
);
}
// Checks if the LogConfigParser class is able to transform data structures
...
...
@@ -204,14 +204,14 @@ TEST(LoggingTest, multipleLoggingDestinations) {
EXPECT_NO_THROW
(
parser
.
parseConfiguration
(
config
));
ASSERT_EQ
(
1
,
storage
->
l
ogging
_i
nfo
_
.
size
());
ASSERT_EQ
(
1
,
storage
->
getL
ogging
I
nfo
()
.
size
());
EXPECT_EQ
(
"kea"
,
storage
->
l
ogging
_i
nfo
_
[
0
].
name_
);
EXPECT_EQ
(
0
,
storage
->
l
ogging
_i
nfo
_
[
0
].
debuglevel_
);
EXPECT_EQ
(
isc
::
log
::
INFO
,
storage
->
l
ogging
_i
nfo
_
[
0
].
severity_
);
ASSERT_EQ
(
2
,
storage
->
l
ogging
_i
nfo
_
[
0
].
destinations_
.
size
());
EXPECT_EQ
(
"logfile.txt"
,
storage
->
l
ogging
_i
nfo
_
[
0
].
destinations_
[
0
].
output_
);
EXPECT_EQ
(
"stdout"
,
storage
->
l
ogging
_i
nfo
_
[
0
].
destinations_
[
1
].
output_
);
EXPECT_EQ
(
"kea"
,
storage
->
getL
ogging
I
nfo
()
[
0
].
name_
);
EXPECT_EQ
(
0
,
storage
->
getL
ogging
I
nfo
()
[
0
].
debuglevel_
);
EXPECT_EQ
(
isc
::
log
::
INFO
,
storage
->
getL
ogging
I
nfo
()
[
0
].
severity_
);
ASSERT_EQ
(
2
,
storage
->
getL
ogging
I
nfo
()
[
0
].
destinations_
.
size
());
EXPECT_EQ
(
"logfile.txt"
,
storage
->
getL
ogging
I
nfo
()
[
0
].
destinations_
[
0
].
output_
);
EXPECT_EQ
(
"stdout"
,
storage
->
getL
ogging
I
nfo
()
[
0
].
destinations_
[
1
].
output_
);
}
/// @todo There is no easy way to test applyConfiguration() and defaultLogging().
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment