::
- "%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:
- %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
::
- "%-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
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) {
#!/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
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 $?
#!/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
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 -
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.
#!/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
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 $?
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 $?
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 $?
.
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 $?
#!/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
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 $?
.
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 $?
#!/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
.
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 $?
-// 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
}
};
-
-
// 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.
string logname_; // Name of this logger
};
-
// Convenience function to read an output log file and check that each line
// contains the expected message ID
//
"[[: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);
#!/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
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 $?
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 $?
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 $?