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
ISC Open Source Projects
Kea
Commits
67c6c448
Commit
67c6c448
authored
May 23, 2011
by
Stephen Morris
Browse files
[trac555] Added OutputOption structure and test
parent
862e13c5
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/lib/log/Makefile.am
View file @
67c6c448
...
...
@@ -22,6 +22,7 @@ liblog_la_SOURCES += message_exception.h
liblog_la_SOURCES
+=
message_initializer.cc message_initializer.h
liblog_la_SOURCES
+=
message_reader.cc message_reader.h
liblog_la_SOURCES
+=
message_types.h
liblog_la_SOURCES
+=
output_option.h
liblog_la_SOURCES
+=
root_logger_name.cc root_logger_name.h
EXTRA_DIST
=
README
...
...
src/lib/log/output_option.h
0 → 100644
View file @
67c6c448
// Copyright (C) 2011 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 __OUTPUT_OPTION_H
#define __OUTPUT_OPTION_H
#include
<cstddef>
#include
<cstdint>
#include
<string>
/// \brief Logger Output Option
///
/// The logging configuration options are a list of logger specifications, each
/// with one or more output options. This class represents an output option;
/// one or more of these are attached to a LoggerSpecification object which is
/// then passed to the LoggerManager to configure the logger.
///
/// Although there are three distinct output types (console, file, syslog) and
/// the options for each do not really overlap. Although it is tempting to
/// define a base OutputOption class and derive a class for each type
/// (ConsoleOutputOptions etc.), it would be messy to use in practice. At
/// some point the exact class would have to be known to get the class-specific
/// options and the (pointer to) the base class cast to the appropriate type.
/// Instead, this "struct" contains the union of all output options; it is up
/// to the caller to cherry-pick the members it needs.
///
/// One final note: this object holds data and does no computation. For this
/// reason, it is a "struct" and members are accessed directly instead of
/// through methods.
namespace
isc
{
namespace
log
{
struct
OutputOption
{
/// Destinations. Prefixed "DEST_" to avoid problems with the C stdio.h
/// FILE type.
typedef
enum
{
DEST_CONSOLE
=
0
,
DEST_FILE
=
1
,
DEST_SYSLOG
=
2
}
Destination
;
/// If console, stream on which messages are output
typedef
enum
{
STR_STDERR
=
0
,
// Default console stream is stderr
STR_STDOUT
=
1
}
Stream
;
/// Members. The default sets everything to 0, which why the
/// stderr/stdout numbers (above) are reversed.
Destination
destination
;
///< Where the output should go
Stream
stream
;
///< stdout/stderr if console output
bool
flush
;
///< true to flush after each message
std
::
string
facility
;
///< syslog facility
std
::
string
filename
;
///< Filename if file output
size_t
maxsize
;
///< 0 if no maximum size
int
maxver
;
///< Maximum versions (none if <= 0)
};
}
// namespace log
}
// namespace isc
#endif // __OUTPUT_OPTION_H
src/lib/log/tests/Makefile.am
View file @
67c6c448
...
...
@@ -13,16 +13,17 @@ CLEANFILES = *.gcno *.gcda
TESTS
=
if
HAVE_GTEST
TESTS
+=
run_unittests
run_unittests_SOURCES
=
root_logger_name_unittest.cc
run_unittests_SOURCES
+=
logger_unittest.cc
run_unittests_SOURCES
+=
logger_level_unittest.cc
run_unittests_SOURCES
=
run_unittests.cc
run_unittests_SOURCES
+=
log_formatter_unittest.cc
run_unittests_SOURCES
+=
logger_level_impl_unittest.cc
run_unittests_SOURCES
+=
logger_level_unittest.cc
run_unittests_SOURCES
+=
logger_unittest.cc
run_unittests_SOURCES
+=
message_dictionary_unittest.cc
run_unittests_SOURCES
+=
message_reader_unittest.cc
run_unittests_SOURCES
+=
message_initializer_unittest.cc
run_unittests_SOURCES
+=
message_initializer_unittest_2.cc
run_unittests_SOURCES
+=
run_unittests.cc
run_unittests_SOURCES
+=
log_formatter_unittest.cc
run_unittests_SOURCES
+=
message_initializer_unittest.cc
run_unittests_SOURCES
+=
message_reader_unittest.cc
run_unittests_SOURCES
+=
output_option_unittest.cc
run_unittests_SOURCES
+=
root_logger_name_unittest.cc
run_unittests_CPPFLAGS
=
$(AM_CPPFLAGS)
$(GTEST_INCLUDES)
run_unittests_LDFLAGS
=
$(AM_LDFLAGS)
$(GTEST_LDFLAGS)
$(LOG4CPLUS_LDFLAGS)
...
...
src/lib/log/tests/output_option_unittest.cc
0 → 100644
View file @
67c6c448
// Copyright (C) 2011 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.
#include
<string>
#include
<gtest/gtest.h>
#include
<log/output_option.h>
using
namespace
isc
::
log
;
using
namespace
std
;
/// \brief OutputOption Test
class
OutputOptionTest
:
public
::
testing
::
Test
{
public:
OutputOptionTest
()
{}
~
OutputOptionTest
()
{}
};
// As OutputOption is a struct, the only meaningful test is to check that it
// initializes correctly.
TEST_F
(
OutputOptionTest
,
Initialization
)
{
OutputOption
option
;
EXPECT_EQ
(
OutputOption
::
DEST_CONSOLE
,
option
.
destination
);
EXPECT_EQ
(
OutputOption
::
STR_STDERR
,
option
.
stream
);
EXPECT_FALSE
(
option
.
flush
);
EXPECT_EQ
(
string
(
""
),
option
.
facility
);
EXPECT_EQ
(
string
(
""
),
option
.
filename
);
EXPECT_EQ
(
0
,
option
.
maxsize
);
EXPECT_EQ
(
0
,
option
.
maxver
);
}
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