Commit 4140b1a9 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[1745] Add pid to all log messages

Also adjust affected tests accordingly.
parent 2f15c783
......@@ -203,7 +203,7 @@ void LoggerManagerImpl::setConsoleAppenderLayout(
log4cplus::SharedAppenderPtr& appender)
{
// Create the pattern we want for the output - local time.
string pattern = "%D{%Y-%m-%d %H:%M:%S.%q} %-5p [%c] %m\n";
string pattern = "%D{%Y-%m-%d %H:%M:%S.%q} %-5p [%c/%i] %m\n";
// Finally the text of the message
auto_ptr<log4cplus::Layout> layout(new log4cplus::PatternLayout(pattern));
......
......@@ -127,3 +127,10 @@ check-local:
$(SHELL) $(abs_builddir)/local_file_test.sh
$(SHELL) $(abs_builddir)/logger_lock_test.sh
$(SHELL) $(abs_builddir)/severity_test.sh
noinst_SCRIPTS = console_test.sh
noinst_SCRIPTS += destination_test.sh
noinst_SCRIPTS += init_logger_test.sh
noinst_SCRIPTS += local_file_test.sh
noinst_SCRIPTS += logger_lock_test.sh
noinst_SCRIPTS += severity_test.sh
......@@ -20,6 +20,8 @@ echo $testname
failcount=0
tempfile=@abs_builddir@/destination_test_tempfile_$$
destfile1_tmp=@abs_builddir@/destination_test_destfile_1_tmp_$$
destfile2_tmp=@abs_builddir@/destination_test_destfile_2_tmp_$$
destfile1=@abs_builddir@/destination_test_destfile_1_$$
destfile2=@abs_builddir@/destination_test_destfile_2_$$
......@@ -40,7 +42,11 @@ FATAL [example.beta] LOG_BAD_SEVERITY unrecognized log severity: beta_fatal
ERROR [example.beta] LOG_BAD_DESTINATION unrecognized log destination: beta_error
.
rm -f $destfile1 $destfile2
./logger_example -s error -f $destfile1 -f $destfile2
./logger_example -s error -f $destfile1_tmp -f $destfile2_tmp
# strip the pids
sed -e 's/\[\([a-z0-9\.]\+\)\/\([0-9]\+\)\]/[\1]/' < $destfile1_tmp > $destfile1
sed -e 's/\[\([a-z0-9\.]\+\)\/\([0-9]\+\)\]/[\1]/' < $destfile2_tmp > $destfile2
echo -n " - destination 1:"
cut -d' ' -f3- $destfile1 | diff $tempfile -
......@@ -50,9 +56,16 @@ echo -n " - destination 2:"
cut -d' ' -f3- $destfile2 | diff $tempfile -
passfail $?
# Tidy up.
rm -f $tempfile $destfile1_tmp $destfile2_tmp $destfile1 $destfile2
echo "2. Two loggers, different destinations and severities"
rm -f $destfile1 $destfile2
./logger_example -l example -s info -f $destfile1 -l alpha -s warn -f $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\.]\+\)\/\([0-9]\+\)\]/[\1]/' < $destfile1_tmp > $destfile1
sed -e 's/\[\([a-z0-9\.]\+\)\/\([0-9]\+\)\]/[\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.
......@@ -86,6 +99,6 @@ else
fi
# Tidy up.
rm -f $tempfile $destfile1 $destfile2
rm -f $tempfile $destfile1_tmp $destfile2_tmp $destfile1 $destfile2
exit $failcount
......@@ -21,6 +21,7 @@ echo $testname
failcount=0
tempfile=@abs_builddir@/init_logger_test_tempfile_$$
destfile_tmp=@abs_builddir@/init_logger_test_destfile_tmp_$$
destfile=@abs_builddir@/init_logger_test_destfile_$$
passfail() {
......@@ -45,6 +46,7 @@ ERROR [bind10.log] LOG_DUPLICATE_MESSAGE_ID duplicate message ID (error) in comp
FATAL [bind10.log] LOG_NO_MESSAGE_ID line fatal: message definition line found without a message ID
.
B10_LOGGER_DESTINATION=stdout B10_LOGGER_SEVERITY=DEBUG B10_LOGGER_DBGLEVEL=99 ./init_logger_test | \
sed -e 's/\[\([a-z0-9\.]\+\)\/\([0-9]\+\)\]/[\1]/' | \
cut -d' ' -f3- | diff $tempfile -
passfail $?
......@@ -58,6 +60,7 @@ ERROR [bind10.log] LOG_DUPLICATE_MESSAGE_ID duplicate message ID (error) in comp
FATAL [bind10.log] LOG_NO_MESSAGE_ID line fatal: message definition line found without a message ID
.
B10_LOGGER_DESTINATION=stdout B10_LOGGER_SEVERITY=DEBUG B10_LOGGER_DBGLEVEL=50 ./init_logger_test | \
sed -e 's/\[\([a-z0-9\.]\+\)\/\([0-9]\+\)\]/[\1]/' | \
cut -d' ' -f3- | diff $tempfile -
passfail $?
......@@ -68,6 +71,7 @@ ERROR [bind10.log] LOG_DUPLICATE_MESSAGE_ID duplicate message ID (error) in comp
FATAL [bind10.log] LOG_NO_MESSAGE_ID line fatal: message definition line found without a message ID
.
B10_LOGGER_DESTINATION=stdout B10_LOGGER_SEVERITY=WARN ./init_logger_test | \
sed -e 's/\[\([a-z0-9\.]\+\)\/\([0-9]\+\)\]/[\1]/' | \
cut -d' ' -f3- | diff $tempfile -
passfail $?
......@@ -77,20 +81,23 @@ echo -n " - stdout: "
cat > $tempfile << .
FATAL [bind10.log] LOG_NO_MESSAGE_ID line fatal: message definition line found without a message ID
.
rm -f $destfile
B10_LOGGER_SEVERITY=FATAL B10_LOGGER_DESTINATION=stdout ./init_logger_test 1> $destfile
rm -f $destfile_tmp $destfile
B10_LOGGER_SEVERITY=FATAL B10_LOGGER_DESTINATION=stdout ./init_logger_test 1> $destfile_tmp
sed -e 's/\[\([a-z0-9\.]\+\)\/\([0-9]\+\)\]/[\1]/' < $destfile_tmp > $destfile
cut -d' ' -f3- $destfile | diff $tempfile -
passfail $?
echo -n " - stderr: "
rm -f $destfile
B10_LOGGER_SEVERITY=FATAL B10_LOGGER_DESTINATION=stderr ./init_logger_test 2> $destfile
rm -f $destfile_tmp $destfile
B10_LOGGER_SEVERITY=FATAL B10_LOGGER_DESTINATION=stderr ./init_logger_test 2> $destfile_tmp
sed -e 's/\[\([a-z0-9\.]\+\)\/\([0-9]\+\)\]/[\1]/' < $destfile_tmp > $destfile
cut -d' ' -f3- $destfile | diff $tempfile -
passfail $?
echo -n " - file: "
rm -f $destfile
B10_LOGGER_SEVERITY=FATAL B10_LOGGER_DESTINATION=$destfile ./init_logger_test
rm -f $destfile_tmp $destfile
B10_LOGGER_SEVERITY=FATAL B10_LOGGER_DESTINATION=$destfile_tmp ./init_logger_test
sed -e 's/\[\([a-z0-9\.]\+\)\/\([0-9]\+\)\]/[\1]/' < $destfile_tmp > $destfile
cut -d' ' -f3- $destfile | diff $tempfile -
passfail $?
......@@ -105,6 +112,6 @@ else
fi
# Tidy up.
rm -f $tempfile $destfile
rm -f $tempfile $destfile_tmp $destfile
exit $failcount
......@@ -51,7 +51,9 @@ FATAL [example.beta] LOG_BAD_SEVERITY unrecognized log severity: beta_fatal
ERROR [example.beta] LOG_BAD_DESTINATION unrecognized log destination: beta_error
WARN [example.beta] LOG_BAD_STREAM bad log console output stream: beta_warn
.
./logger_example -c stdout -s warn $localmes | cut -d' ' -f3- | diff $tempfile -
./logger_example -c stdout -s warn $localmes | \
sed -e 's/\[\([a-z0-9\.]\+\)\/\([0-9]\+\)\]/[\1]/' | \
cut -d' ' -f3- | diff $tempfile -
passfail $?
echo -n "2. Report error if unable to read local message file:"
......@@ -66,7 +68,9 @@ ERROR [example.beta] LOG_BAD_DESTINATION unrecognized log destination: beta_erro
WARN [example.beta] LOG_BAD_STREAM bad log console output stream: beta_warn
.
rm -f $localmes
./logger_example -c stdout -s warn $localmes | cut -d' ' -f3- | diff $tempfile -
./logger_example -c stdout -s warn $localmes | \
sed -e 's/\[\([a-z0-9\.]\+\)\/\([0-9]\+\)\]/[\1]/' | \
cut -d' ' -f3- | diff $tempfile -
passfail $?
if [ $failcount -eq 0 ]; then
......
......@@ -36,7 +36,8 @@ INFO [bind10.log] LOG_LOCK_TEST_MESSAGE this is a test message.
LOGGER_LOCK_TEST: UNLOCK
.
rm -f $destfile
B10_LOGGER_SEVERITY=INFO B10_LOGGER_DESTINATION=stdout ./logger_lock_test > $destfile
B10_LOGGER_SEVERITY=INFO B10_LOGGER_DESTINATION=stdout ./logger_lock_test | \
sed -e 's/\[\([a-z0-9\.]\+\)\/\([0-9]\+\)\]/[\1]/' > $destfile
cut -d' ' -f3- $destfile | diff $tempfile -
passfail $?
......
......@@ -43,7 +43,9 @@ ERROR [example.beta] LOG_BAD_DESTINATION unrecognized log destination: beta_erro
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 | cut -d' ' -f3- | diff $tempfile -
./logger_example -c stdout | \
sed -e 's/\[\([a-z0-9\.]\+\)\/\([0-9]\+\)\]/[\1]/' | \
cut -d' ' -f3- | diff $tempfile -
passfail $?
echo -n "2. Severity filter:"
......@@ -53,7 +55,9 @@ ERROR [example] LOG_READING_LOCAL_FILE reading local message file dummy/file
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 | cut -d' ' -f3- | diff $tempfile -
./logger_example -c stdout -s error | \
sed -e 's/\[\([a-z0-9\.]\+\)\/\([0-9]\+\)\]/[\1]/' | \
cut -d' ' -f3- | diff $tempfile -
passfail $?
echo -n "3. Debug level:"
......@@ -72,7 +76,9 @@ 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
DEBUG [example.beta] LOG_BAD_SEVERITY unrecognized log severity: beta/25
.
./logger_example -c stdout -s debug -d 25 | cut -d' ' -f3- | diff $tempfile -
./logger_example -c stdout -s debug -d 25 | \
sed -e 's/\[\([a-z0-9\.]\+\)\/\([0-9]\+\)\]/[\1]/' | \
cut -d' ' -f3- | diff $tempfile -
passfail $?
if [ $failcount -eq 0 ]; then
......
#!/bin/sh
"$1" 2>&1 | cut -d\ -f3- | diff - "$2" 1>&2
"$1" 2>&1 | sed -e 's/\[\([a-z0-9\.]\+\)\/\([0-9]\+\)\]/[\1]/' | cut -d\ -f3- | diff - "$2" 1>&2
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment