mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 14:05:33 +00:00
[#1150] Added %t in log patterns
This commit is contained in:
@@ -636,13 +636,13 @@ below:
|
||||
|
||||
::
|
||||
|
||||
"%D{%Y-%m-%d %H:%M:%S.%q} %-5p [%c/%i] %m\n";
|
||||
"%D{%Y-%m-%d %H:%M:%S.%q} %-5p [%c/%i/%t] %m\n";
|
||||
|
||||
and a typical log produced by this pattern would look somethng like this:
|
||||
|
||||
::
|
||||
|
||||
2019-08-05 14:27:45.871 DEBUG [kea-dhcp4.dhcpsrv/8475] DHCPSRV_TIMERMGR_START_TIMER starting timer: reclaim-expired-leases
|
||||
2019-08-05 14:27:45.871 DEBUG [kea-dhcp4.dhcpsrv/8475/12345] DHCPSRV_TIMERMGR_START_TIMER starting timer: reclaim-expired-leases
|
||||
|
||||
That breaks down as like so:
|
||||
|
||||
@@ -665,6 +665,11 @@ That breaks down as like so:
|
||||
- %i
|
||||
The process ID. From the example log: ``8475``
|
||||
|
||||
- %t
|
||||
The thread ID. From the example log: ``12345``.
|
||||
Note the format of the thread ID is OS dependent: e.g. on some systems
|
||||
it is an address so is displayed in hexadecimal.
|
||||
|
||||
- %m
|
||||
The log message itself. Keg log messages all begin with a message
|
||||
identifier followed by arbitrary log text. Every message in Kea has
|
||||
@@ -699,7 +704,7 @@ The default for pattern for syslog output is as follows:
|
||||
|
||||
::
|
||||
|
||||
"%-5p [%c] %m\n";
|
||||
"%-5p [%c/%t] %m\n";
|
||||
|
||||
You can see that it omits the date and time as well the process ID as this
|
||||
information is typically output by syslog. Note that Kea uses the pattern
|
||||
|
@@ -18,13 +18,13 @@ namespace isc {
|
||||
namespace log {
|
||||
|
||||
/// Default layout pattern for console logs
|
||||
const std::string OutputOption::DEFAULT_CONSOLE_PATTERN = "%D{%Y-%m-%d %H:%M:%S.%q} %-5p [%c/%i] %m\n";
|
||||
const std::string OutputOption::DEFAULT_CONSOLE_PATTERN = "%D{%Y-%m-%d %H:%M:%S.%q} %-5p [%c/%i/%t] %m\n";
|
||||
|
||||
/// Default layout pattern for file logs
|
||||
const std::string OutputOption::DEFAULT_FILE_PATTERN = "%D{%Y-%m-%d %H:%M:%S.%q} %-5p [%c/%i] %m\n";
|
||||
const std::string OutputOption::DEFAULT_FILE_PATTERN = "%D{%Y-%m-%d %H:%M:%S.%q} %-5p [%c/%i/%t] %m\n";
|
||||
|
||||
/// Default layout pattern for syslog logs
|
||||
const std::string OutputOption::DEFAULT_SYSLOG_PATTERN = "%-5p [%c] %m\n";
|
||||
const std::string OutputOption::DEFAULT_SYSLOG_PATTERN = "%-5p [%c/%t] %m\n";
|
||||
|
||||
OutputOption::Destination
|
||||
getDestination(const std::string& dest_str) {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2012-2016 Internet Systems Consortium, Inc. ("ISC")
|
||||
# Copyright (C) 2012-2020 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
|
||||
@@ -32,7 +32,7 @@ INFO [buffertest.log] LOG_BAD_SEVERITY unrecognized log severity: info
|
||||
INFO [buffertest.log] LOG_BAD_SEVERITY unrecognized log severity: info
|
||||
.
|
||||
./buffer_logger_test 2>&1 | \
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\]/[\1]/' | \
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\/\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' | \
|
||||
cut -d' ' -f3- | diff $tempfile -
|
||||
passfail $?
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC")
|
||||
# Copyright (C) 2011-2020 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
|
||||
@@ -36,9 +36,11 @@ ERROR [example.beta] LOG_BAD_DESTINATION unrecognized log destination: beta_erro
|
||||
rm -f $destfile1 $destfile2
|
||||
./logger_example -s error -f $destfile1_tmp -f $destfile2_tmp
|
||||
|
||||
# strip the pids
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\]/[\1]/' < $destfile1_tmp > $destfile1
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\]/[\1]/' < $destfile2_tmp > $destfile2
|
||||
# strip the pids and thread ids
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\/\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' < $destfile1_tmp > $destfile1
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\/\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' < $destfile2_tmp > $destfile2
|
||||
# strip the thread ids
|
||||
|
||||
|
||||
echo -n " - destination 1:"
|
||||
cut -d' ' -f3- $destfile1 | diff $tempfile -
|
||||
@@ -55,9 +57,9 @@ echo "2. Two loggers, different destinations and severities"
|
||||
rm -f $destfile1 $destfile2
|
||||
./logger_example -l example -s info -f $destfile1_tmp -l alpha -s warn -f $destfile2_tmp
|
||||
|
||||
# strip the pids
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\]/[\1]/' < $destfile1_tmp > $destfile1
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\]/[\1]/' < $destfile2_tmp > $destfile2
|
||||
# strip the pids and thread ids
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\/\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' < $destfile1_tmp > $destfile1
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\/\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' < $destfile2_tmp > $destfile2
|
||||
|
||||
# All output for example and example.beta should have gone to destfile1.
|
||||
# Output for example.alpha should have done to destfile2.
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC")
|
||||
# Copyright (C) 2011-2020 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
|
||||
@@ -38,7 +38,7 @@ ERROR [kea.log] LOG_DUPLICATE_MESSAGE_ID duplicate message ID (error) in compile
|
||||
FATAL [kea.log] LOG_NO_MESSAGE_ID line fatal: message definition line found without a message ID
|
||||
.
|
||||
KEA_LOGGER_DESTINATION=stdout KEA_LOGGER_SEVERITY=DEBUG KEA_LOGGER_DBGLEVEL=99 ./init_logger_test | \
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\]/[\1]/' | \
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\/\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' | \
|
||||
cut -d' ' -f3- | diff $tempfile -
|
||||
passfail $?
|
||||
|
||||
@@ -52,7 +52,7 @@ ERROR [kea.log] LOG_DUPLICATE_MESSAGE_ID duplicate message ID (error) in compile
|
||||
FATAL [kea.log] LOG_NO_MESSAGE_ID line fatal: message definition line found without a message ID
|
||||
.
|
||||
KEA_LOGGER_DESTINATION=stdout KEA_LOGGER_SEVERITY=DEBUG KEA_LOGGER_DBGLEVEL=50 ./init_logger_test | \
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\]/[\1]/' | \
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\/\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' | \
|
||||
cut -d' ' -f3- | diff $tempfile -
|
||||
passfail $?
|
||||
|
||||
@@ -63,7 +63,7 @@ ERROR [kea.log] LOG_DUPLICATE_MESSAGE_ID duplicate message ID (error) in compile
|
||||
FATAL [kea.log] LOG_NO_MESSAGE_ID line fatal: message definition line found without a message ID
|
||||
.
|
||||
KEA_LOGGER_DESTINATION=stdout KEA_LOGGER_SEVERITY=WARN ./init_logger_test | \
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\]/[\1]/' | \
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\/\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' | \
|
||||
cut -d' ' -f3- | diff $tempfile -
|
||||
passfail $?
|
||||
|
||||
@@ -75,21 +75,21 @@ FATAL [kea.log] LOG_NO_MESSAGE_ID line fatal: message definition line found with
|
||||
.
|
||||
rm -f $destfile_tmp $destfile
|
||||
KEA_LOGGER_SEVERITY=FATAL KEA_LOGGER_DESTINATION=stdout ./init_logger_test 1> $destfile_tmp
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\]/[\1]/' < $destfile_tmp > $destfile
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\/\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' < $destfile_tmp > $destfile
|
||||
cut -d' ' -f3- $destfile | diff $tempfile -
|
||||
passfail $?
|
||||
|
||||
echo -n " - stderr: "
|
||||
rm -f $destfile_tmp $destfile
|
||||
KEA_LOGGER_SEVERITY=FATAL KEA_LOGGER_DESTINATION=stderr ./init_logger_test 2> $destfile_tmp
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\]/[\1]/' < $destfile_tmp > $destfile
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\/\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' < $destfile_tmp > $destfile
|
||||
cut -d' ' -f3- $destfile | diff $tempfile -
|
||||
passfail $?
|
||||
|
||||
echo -n " - file: "
|
||||
rm -f $destfile_tmp $destfile
|
||||
KEA_LOGGER_SEVERITY=FATAL KEA_LOGGER_DESTINATION=$destfile_tmp ./init_logger_test
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\]/[\1]/' < $destfile_tmp > $destfile
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\/\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' < $destfile_tmp > $destfile
|
||||
cut -d' ' -f3- $destfile | diff $tempfile -
|
||||
passfail $?
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC")
|
||||
# Copyright (C) 2011-2020 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
|
||||
@@ -44,7 +44,7 @@ ERROR [example.beta] LOG_BAD_DESTINATION unrecognized log destination: beta_erro
|
||||
WARN [example.beta] LOG_BAD_STREAM bad log console output stream: beta_warn
|
||||
.
|
||||
./logger_example -c stdout -s warn $localmes | \
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\]/[\1]/' | \
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\/\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' | \
|
||||
cut -d' ' -f3- | diff $tempfile -
|
||||
passfail $?
|
||||
|
||||
@@ -61,7 +61,7 @@ WARN [example.beta] LOG_BAD_STREAM bad log console output stream: beta_warn
|
||||
.
|
||||
rm -f $localmes
|
||||
./logger_example -c stdout -s warn $localmes | \
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\]/[\1]/' | \
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\/\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' | \
|
||||
cut -d' ' -f3- | diff $tempfile -
|
||||
passfail $?
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2012-2016 Internet Systems Consortium, Inc. ("ISC")
|
||||
# Copyright (C) 2012-2020 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
|
||||
@@ -30,7 +30,7 @@ LOGGER_LOCK_TEST: UNLOCK
|
||||
.
|
||||
rm -f $destfile
|
||||
KEA_LOGGER_SEVERITY=INFO KEA_LOGGER_DESTINATION=stdout ./logger_lock_test | \
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\]/[\1]/' > $destfile
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\/\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' > $destfile
|
||||
cut -d' ' -f3- $destfile | diff $tempfile -
|
||||
passfail $?
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2011-2017 Internet Systems Consortium, Inc. ("ISC")
|
||||
// Copyright (C) 2011-2020 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
|
||||
@@ -50,8 +50,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Convenience class to create the specification for the logger "filelogger",
|
||||
// which, as the name suggests, logs to a file. It remembers the file name and
|
||||
// deletes the file when instance of the class is destroyed.
|
||||
@@ -134,7 +132,6 @@ private:
|
||||
string logname_; // Name of this logger
|
||||
};
|
||||
|
||||
|
||||
// Convenience function to read an output log file and check that each line
|
||||
// contains the expected message ID
|
||||
//
|
||||
@@ -392,8 +389,8 @@ TEST_F(LoggerManagerTest, checkLayoutPattern) {
|
||||
"[[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}\\.[[:digit:]]+[[:space:]]"
|
||||
// %-5p
|
||||
"[[:alpha:]]{1,5}[[:space:]]"
|
||||
// [%c/%i]
|
||||
"\\[[[:alnum:]\\-\\.]+/[[:digit:]]+\\][[:space:]]"
|
||||
// [%c/%i/%t]
|
||||
"\\[[[:alnum:]\\-\\.]+/[[:digit:]]+/(0x)?[[:xdigit:]]+\\][[:space:]]"
|
||||
);
|
||||
|
||||
const int re = regexec(*regex, line.c_str(), 0, NULL, 0);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC")
|
||||
# Copyright (C) 2011-2020 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
|
||||
@@ -36,7 +36,7 @@ WARN [example.beta] LOG_BAD_STREAM bad log console output stream: beta_warn
|
||||
INFO [example.beta] LOG_READ_ERROR error reading from message file beta: info
|
||||
.
|
||||
./logger_example -c stdout | \
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\]/[\1]/' | \
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\/\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' | \
|
||||
cut -d' ' -f3- | diff $tempfile -
|
||||
passfail $?
|
||||
|
||||
@@ -48,7 +48,7 @@ FATAL [example.beta] LOG_BAD_SEVERITY unrecognized log severity: beta_fatal
|
||||
ERROR [example.beta] LOG_BAD_DESTINATION unrecognized log destination: beta_error
|
||||
.
|
||||
./logger_example -c stdout -s error | \
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\]/[\1]/' | \
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\/\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' | \
|
||||
cut -d' ' -f3- | diff $tempfile -
|
||||
passfail $?
|
||||
|
||||
@@ -69,7 +69,7 @@ INFO [example.beta] LOG_READ_ERROR error reading from message file beta: info
|
||||
DEBUG [example.beta] LOG_BAD_SEVERITY unrecognized log severity: beta/25
|
||||
.
|
||||
./logger_example -c stdout -s debug -d 25 | \
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\]/[\1]/' | \
|
||||
sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\/\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' | \
|
||||
cut -d' ' -f3- | diff $tempfile -
|
||||
passfail $?
|
||||
|
||||
|
Reference in New Issue
Block a user