Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
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
a5e103c0
Commit
a5e103c0
authored
Sep 25, 2014
by
Tomek Mrugalski
🛰
Browse files
[master] Merge branch 'trac3591' (logging lockfile fix)
Conflicts: ChangeLog Makefile.am src/lib/dhcpsrv/daemon.cc
parents
4f942fc1
d4556e1d
Changes
33
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
a5e103c0
838. [bug] tomek
Kea components now use the KEA_LOCKFILE_DIR environment variable
to specify the directory of the logging lockfile. Locking can be
disabled completely by setting the variable to 'none'.
(Trac #3591, git d4556e1d21766b94f2f0cda59df15e47e6f2676e)
837. [bug,doc] tomek
Logging configuration examples in kea.conf fixed. Also updated
Kea documentation for logging.
...
...
Makefile.am
View file @
a5e103c0
...
...
@@ -122,6 +122,7 @@ cppcheck:
# These steps are necessary during installation
install-exec-hook
:
mkdir
-p
$(DESTDIR)${localstatedir}
/log/
mkdir
-p
$(DESTDIR)${localstatedir}
/run/
${PACKAGE_NAME}
### include tool to generate documentation from log message specifications
### in the distributed tarball:
...
...
doc/guide/logging.xml
View file @
a5e103c0
...
...
@@ -20,7 +20,7 @@
<title>
Logging
</title>
<section>
<title>
Logging
c
onfiguration
</title>
<title>
Logging
C
onfiguration
</title>
<para>
During its operation Kea may produce many messages. They differ in
...
...
@@ -426,7 +426,7 @@ TODO; there's a ticket to determine these levels, see #1074
</section>
<section>
<title>
Example Logger
c
onfigurations
</title>
<title>
Example Logger
C
onfigurations
</title>
<para>
In this example we want to set the global logging to
...
...
@@ -561,4 +561,76 @@ file be created.</para>
</section>
<section>
<title>
Logging During Kea Startup
</title>
<para>
The logging configuration is specified in the configuration file.
However, when Kea starts, the file is not read until some way into the
initialization process. Prior to that, the logging settings are
set to default values, although it is possible to modify some
aspects of the settings by means of environment variables. Note
that in the absence of any logging configuration in the configuration
file, the settings of (possibly modified) default configuration will
persist while the program is running.
</para>
<para>
The following environment variables can be used to control the
behavio of logging during startup:
</para>
<variablelist>
<varlistentry>
<term>
KEA_LOCKFILE_DIR
</term>
<listitem><para>
Specifies a directory where logging system should create its
lock file. If not specified, it is
<replaceable>
prefix
</replaceable>
/var/run/kea, where
<replaceable>
prefix
</replaceable>
defaults to /usr/local.
This variable must not end
with a slash. There is one special value: "none", which
instructs Kea to not create lock file at all. This may cause
issues if several processes log to the same file.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
KEA_LOGGER_DESTINATION
</term>
<listitem><para>
Specifies logging output. There are several special values.
<variablelist>
<varlistentry>
<term>
stdout
</term>
<listitem><para>
Log to standard output.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
stderr
</term>
<listitem><para>
Log to standard error.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
syslog
<optional>
:
<replaceable>
fac
</replaceable></optional></term>
<listitem><para>
Log via syslog. The optional
<replaceable>
fac
</replaceable>
(which is
separated from the word "syslog" by a colon)
specifies the
facility to be used for the log messages. Unless
specified, messages will be logged using the
facility "local0".
</para></listitem>
</varlistentry>
</variablelist>
Any other value is treated as a name
of the output file. If not specified otherwise, Kea will log to
standard output.
</para></listitem>
</varlistentry>
</variablelist>
</section>
</chapter>
src/bin/d2/d_controller.cc
View file @
a5e103c0
...
...
@@ -453,17 +453,6 @@ DControllerBase::~DControllerBase() {
};
// namespace isc::d2
// Provide an implementation until we figure out a better way to do this.
void
dhcp
::
Daemon
::
loggerInit
(
const
char
*
log_name
,
bool
verbose
)
{
setenv
(
"KEA_LOCKFILE_DIR_FROM_BUILD"
,
"/tmp"
,
1
);
setenv
(
"KEA_LOGGER_ROOT"
,
log_name
,
0
);
setenv
(
"KEA_LOGGER_SEVERITY"
,
(
verbose
?
"DEBUG"
:
"INFO"
),
0
);
setenv
(
"KEA_LOGGER_DBGLEVEL"
,
"99"
,
0
);
setenv
(
"KEA_LOGGER_DESTINATION"
,
"stdout"
,
0
);
isc
::
log
::
initLogger
();
}
};
// namespace isc
std
::
string
...
...
src/bin/d2/tests/Makefile.am
View file @
a5e103c0
...
...
@@ -14,7 +14,7 @@ EXTRA_DIST += testdata/d2_cfg_tests.json
check-local
:
for
shtest
in
$(SHTESTS)
;
do
\
echo
Running
test
:
$$
shtest
;
\
export
B10
_LOCKFILE_DIR
_FROM_BUILD
=
$(abs_top_builddir)
;
\
export
KEA
_LOCKFILE_DIR
=
$(abs_top_builddir)
;
\
${SHELL}
$(abs_builddir)
/
$$
shtest
||
exit
;
\
done
...
...
src/bin/d2/tests/d2_process_tests.sh.in
View file @
a5e103c0
...
...
@@ -239,3 +239,4 @@ dynamic_reconfiguration_test
shutdown_test "dhcp-ddns.sigterm_test" 15
shutdown_test "dhcp-ddns.sigint_test" 2
version_test "dhcp-ddns.version"
logger_vars_test "dhcp-ddns.variables"
src/bin/dhcp4/bundy_controller.cc
View file @
a5e103c0
...
...
@@ -211,12 +211,5 @@ void ControlledDhcpv4Srv::cleanup() {
}
}
void
Daemon
::
loggerInit
(
const
char
*
log_name
,
bool
verbose
)
{
isc
::
log
::
initLogger
(
log_name
,
(
verbose
?
isc
::
log
::
DEBUG
:
isc
::
log
::
INFO
),
isc
::
log
::
MAX_DEBUG_LEVEL
,
NULL
,
true
);
}
};
};
src/bin/dhcp4/kea_controller.cc
View file @
a5e103c0
...
...
@@ -178,18 +178,5 @@ void ControlledDhcpv4Srv::cleanup() {
// Nothing to do here. No need to disconnect from anything.
}
/// This is a logger initialization for JSON file backend.
/// For now, it's just setting log messages to be printed on stdout.
/// @todo: Implement this properly (see #3427)
void
Daemon
::
loggerInit
(
const
char
*
logger_name
,
bool
verbose
)
{
setenv
(
"KEA_LOCKFILE_DIR_FROM_BUILD"
,
"/tmp"
,
1
);
setenv
(
"KEA_LOGGER_ROOT"
,
logger_name
,
0
);
setenv
(
"KEA_LOGGER_SEVERITY"
,
(
verbose
?
"DEBUG"
:
"INFO"
),
0
);
setenv
(
"KEA_LOGGER_DBGLEVEL"
,
"99"
,
0
);
setenv
(
"KEA_LOGGER_DESTINATION"
,
"stdout"
,
0
);
isc
::
log
::
initLogger
();
}
};
};
src/bin/dhcp4/tests/Makefile.am
View file @
a5e103c0
...
...
@@ -13,7 +13,7 @@ EXTRA_DIST = dhcp4_process_tests.sh.in
check-local
:
for
shtest
in
$(SHTESTS)
;
do
\
echo
Running
test
:
$$
shtest
;
\
export
B10
_LOCKFILE_DIR
_FROM_BUILD
=
$(abs_top_builddir)
;
\
export
KEA
_LOCKFILE_DIR
=
$(abs_top_builddir)
;
\
${SHELL}
$(abs_builddir)
/
$$
shtest
||
exit
;
\
done
...
...
src/bin/dhcp4/tests/dhcp4_process_tests.sh.in
View file @
a5e103c0
...
...
@@ -272,3 +272,4 @@ dynamic_reconfiguration_test
shutdown_test "dhcpv4.sigterm_test" 15
shutdown_test "dhcpv4.sigint_test" 2
version_test "dhcpv4.version"
logger_vars_test "dhcpv4.variables"
src/bin/dhcp6/bundy_controller.cc
View file @
a5e103c0
...
...
@@ -222,12 +222,5 @@ void ControlledDhcpv6Srv::cleanup() {
}
}
void
Daemon
::
loggerInit
(
const
char
*
log_name
,
bool
verbose
)
{
isc
::
log
::
initLogger
(
log_name
,
(
verbose
?
isc
::
log
::
DEBUG
:
isc
::
log
::
INFO
),
isc
::
log
::
MAX_DEBUG_LEVEL
,
NULL
,
true
);
}
};
// end of isc::dhcp namespace
};
// end of isc namespace
src/bin/dhcp6/kea_controller.cc
View file @
a5e103c0
...
...
@@ -185,18 +185,5 @@ void ControlledDhcpv6Srv::cleanup() {
// Nothing to do here. No need to disconnect from anything.
}
/// This is a logger initialization for JSON file backend.
/// For now, it's just setting log messages to be printed on stdout.
/// @todo: Implement this properly (see #3427)
void
Daemon
::
loggerInit
(
const
char
*
logger_name
,
bool
verbose
)
{
setenv
(
"KEA_LOCKFILE_DIR_FROM_BUILD"
,
"/tmp"
,
1
);
setenv
(
"KEA_LOGGER_ROOT"
,
logger_name
,
0
);
setenv
(
"KEA_LOGGER_SEVERITY"
,
(
verbose
?
"DEBUG"
:
"INFO"
),
0
);
setenv
(
"KEA_LOGGER_DBGLEVEL"
,
"99"
,
0
);
setenv
(
"KEA_LOGGER_DESTINATION"
,
"stdout"
,
0
);
isc
::
log
::
initLogger
();
}
};
};
src/bin/dhcp6/tests/Makefile.am
View file @
a5e103c0
...
...
@@ -13,7 +13,7 @@ EXTRA_DIST = $(SHTESTS) dhcp6_process_tests.sh.in
check-local
:
for
shtest
in
$(SHTESTS)
;
do
\
echo
Running
test
:
$$
shtest
;
\
export
B10
_LOCKFILE_DIR
_FROM_BUILD
=
$(abs_top_builddir)
;
\
export
KEA
_LOCKFILE_DIR
=
$(abs_top_builddir)
;
\
${SHELL}
$(abs_builddir)
/
$$
shtest
||
exit
;
\
done
...
...
src/bin/dhcp6/tests/dhcp6_process_tests.sh.in
View file @
a5e103c0
...
...
@@ -276,3 +276,4 @@ dynamic_reconfiguration_test
shutdown_test "dhcpv6.sigterm_test" 15
shutdown_test "dhcpv6.sigint_test" 2
version_test "dhcpv6.version"
logger_vars_test "dhcpv6.variables"
src/bin/keactrl/tests/Makefile.am
View file @
a5e103c0
...
...
@@ -14,6 +14,7 @@ check-local:
for
shtest
in
$(SHTESTS)
;
do
\
echo
Running
test
:
$$
shtest
;
\
chmod
+x
$(abs_builddir)
/
$$
shtest
;
\
export
KEA_LOCKFILE_DIR
=
$(abs_top_builddir)
;
\
export
KEACTRL_BUILD_DIR
=
$(abs_top_builddir)
;
\
export
KEACTRL_CONF
=
$(abs_top_builddir)
/src/bin/keactrl/tests/keactrl_test.conf
;
\
${SHELL}
$(abs_builddir)
/
$$
shtest
||
exit
;
\
...
...
src/lib/dhcpsrv/daemon.cc
View file @
a5e103c0
...
...
@@ -19,6 +19,8 @@
#include <cc/data.h>
#include <boost/bind.hpp>
#include <logging.h>
#include <log/logger_name.h>
#include <log/logger_support.h>
#include <errno.h>
/// @brief provides default implementation for basic daemon operations
...
...
@@ -78,5 +80,15 @@ Daemon::getVerbose() const {
return
(
CfgMgr
::
instance
().
isVerbose
());
}
void
Daemon
::
loggerInit
(
const
char
*
name
,
bool
verbose
)
{
// Initialize logger system
isc
::
log
::
initLogger
(
name
,
isc
::
log
::
DEBUG
,
isc
::
log
::
MAX_DEBUG_LEVEL
,
NULL
);
// Apply default configuration (log INFO or DEBUG to stdout)
isc
::
log
::
setDefaultLoggingOutput
(
verbose
);
}
};
};
src/lib/dhcpsrv/daemon.h
View file @
a5e103c0
...
...
@@ -111,8 +111,10 @@ public:
/// @brief Initializes logger
///
/// This method initializes logger. Currently its implementation is specific
/// to each configuration backend.
/// This method initializes logging system. It also sets the default
/// output to stdout. This is used in early stages of the startup
/// phase before config file and parsed and proper logging details
/// are known.
///
/// @param log_name name used in logger initialization
/// @param verbose verbose mode (true usually enables DEBUG messages)
...
...
src/lib/dhcpsrv/logging.cc
View file @
a5e103c0
...
...
@@ -17,6 +17,7 @@
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <log/logger_specification.h>
#include <log/logger_support.h>
#include <log/logger_manager.h>
#include <log/logger_name.h>
...
...
@@ -156,9 +157,6 @@ void LogConfigParser::applyConfiguration() {
static
const
std
::
string
SYSLOG
=
"syslog"
;
static
const
std
::
string
SYSLOG_COLON
=
"syslog:"
;
// Set locking directory to /tmp
setenv
(
"B10_LOCKFILE_DIR_FROM_BUILD"
,
"/tmp"
,
1
);
std
::
vector
<
LoggerSpecification
>
specs
;
// Now iterate through all specified loggers
...
...
@@ -174,7 +172,7 @@ void LogConfigParser::applyConfiguration() {
for
(
std
::
vector
<
LoggingDestination
>::
const_iterator
dest
=
it
->
destinations_
.
begin
();
dest
!=
it
->
destinations_
.
end
();
++
dest
)
{
// Set up output option according to destination specification
if
(
dest
->
output_
==
STDOUT
)
{
option
.
destination
=
OutputOption
::
DEST_CONSOLE
;
...
...
@@ -219,19 +217,5 @@ void LogConfigParser::applyConfiguration() {
manager
.
process
(
specs
.
begin
(),
specs
.
end
());
}
void
LogConfigParser
::
applyDefaultConfiguration
(
bool
verbose
)
{
LoggerSpecification
spec
(
"kea"
,
(
verbose
?
isc
::
log
::
DEBUG
:
isc
::
log
::
INFO
),
(
verbose
?
99
:
0
));
OutputOption
option
;
option
.
destination
=
OutputOption
::
DEST_CONSOLE
;
option
.
stream
=
OutputOption
::
STR_STDOUT
;
spec
.
addOutputOption
(
option
);
LoggerManager
manager
;
manager
.
process
(
spec
);
}
}
// namespace isc::dhcp
}
// namespace isc
src/lib/dhcpsrv/logging.h
View file @
a5e103c0
...
...
@@ -67,13 +67,6 @@ public:
/// @brief Applies stored configuration
void
applyConfiguration
();
/// @brief Configures default logging
///
/// This method is static,
///
/// @param verbose specifies verbose mode (true forces DEBUG, debuglevel = 99)
void
applyDefaultConfiguration
(
bool
verbose
=
false
);
private:
/// @brief Parses one JSON structure in Logging/loggers" array
...
...
src/lib/log/interprocess/Makefile.am
View file @
a5e103c0
SUBDIRS
=
.
tests
AM_CPPFLAGS
=
-I
$(top_srcdir)
/src/lib
-I
$(top_builddir)
/src/lib
AM_CPPFLAGS
+=
-DLOCKFILE_DIR
=
\"
${localstatedir}
/
${PACKAGE_NAME}
\"
AM_CPPFLAGS
+=
-DLOCKFILE_DIR
=
\"
${localstatedir}
/
run/
${PACKAGE_NAME}
\"
AM_CPPFLAGS
+=
$(BOOST_INCLUDES)
AM_CXXFLAGS
=
$(KEA_CXXFLAGS)
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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