[master] allow different time formats: local, iso8601, iso8601-utc
4518. [func] The "print-time" option in the logging configuration can now take arguments "local", "iso8601" or "iso8601-utc" to indicate the format in which the date and time should be logged. For backward compatibility, "yes" is a synonym for "local". [RT #42585]
This commit is contained in:
@@ -87,8 +87,7 @@ category_fromconf(const cfg_obj_t *ccat, isc_logconfig_t *logconfig) {
|
||||
* in 'cchan' and add it to 'logconfig'.
|
||||
*/
|
||||
static isc_result_t
|
||||
channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig)
|
||||
{
|
||||
channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) {
|
||||
isc_result_t result;
|
||||
isc_logdestination_t dest;
|
||||
unsigned int type;
|
||||
@@ -202,12 +201,21 @@ channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig)
|
||||
|
||||
if (printcat != NULL && cfg_obj_asboolean(printcat))
|
||||
flags |= ISC_LOG_PRINTCATEGORY;
|
||||
if (printtime != NULL && cfg_obj_asboolean(printtime))
|
||||
flags |= ISC_LOG_PRINTTIME;
|
||||
if (printsev != NULL && cfg_obj_asboolean(printsev))
|
||||
flags |= ISC_LOG_PRINTLEVEL;
|
||||
if (buffered != NULL && cfg_obj_asboolean(buffered))
|
||||
flags |= ISC_LOG_BUFFERED;
|
||||
if (printtime != NULL && cfg_obj_isboolean(printtime)) {
|
||||
if (cfg_obj_asboolean(printtime))
|
||||
flags |= ISC_LOG_PRINTTIME;
|
||||
} else if (printtime != NULL) { /* local/iso8601/iso8601-utc */
|
||||
const char *s = cfg_obj_asstring(printtime);
|
||||
flags |= ISC_LOG_PRINTTIME;
|
||||
if (strcasecmp(s, "iso8601") == 0)
|
||||
flags |= ISC_LOG_ISO8601;
|
||||
else if (strcasecmp(s, "iso8601-utc") == 0)
|
||||
flags |= ISC_LOG_ISO8601 | ISC_LOG_UTC;
|
||||
}
|
||||
}
|
||||
|
||||
level = ISC_LOG_INFO;
|
||||
|
||||
14
bin/tests/system/checkconf/bad-printtime.conf
Normal file
14
bin/tests/system/checkconf/bad-printtime.conf
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
logging {
|
||||
channel one {
|
||||
file "one.out";
|
||||
print-time bogus;
|
||||
};
|
||||
};
|
||||
30
bin/tests/system/checkconf/good-printtime.conf
Normal file
30
bin/tests/system/checkconf/good-printtime.conf
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
logging {
|
||||
channel one {
|
||||
file "one.out";
|
||||
print-time no;
|
||||
};
|
||||
channel two {
|
||||
file "two.out";
|
||||
print-time yes;
|
||||
};
|
||||
channel three {
|
||||
file "three.out";
|
||||
print-time local;
|
||||
};
|
||||
channel four {
|
||||
file "four.out";
|
||||
print-time iso8601;
|
||||
};
|
||||
channel five {
|
||||
file "five.out";
|
||||
print-time iso8601-utc;
|
||||
};
|
||||
};
|
||||
@@ -6,8 +6,6 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
# $Id: clean.sh,v 1.4 2011/03/22 16:51:50 smann Exp $
|
||||
|
||||
#
|
||||
# Clean up after log file tests
|
||||
#
|
||||
@@ -19,4 +17,6 @@ rm -rf ns1/named_dir
|
||||
rm -f ns1/named_deflog
|
||||
rm -f ns*/named.lock
|
||||
rm -f ns1/query_log
|
||||
rm -f ns1/named_iso8601
|
||||
rm -f ns1/named_iso8601_utc
|
||||
rm -f ns1/rndc.out.test*
|
||||
|
||||
46
bin/tests/system/logfileconfig/ns1/named.iso8601
Normal file
46
bin/tests/system/logfileconfig/ns1/named.iso8601
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
options {
|
||||
query-source address 10.53.0.1;
|
||||
notify-source 10.53.0.1;
|
||||
transfer-source 10.53.0.1;
|
||||
port 5300;
|
||||
pid-file "named.pid";
|
||||
listen-on port 5300 {
|
||||
10.53.0.1;
|
||||
};
|
||||
listen-on-v6 { none; };
|
||||
recursion no;
|
||||
notify yes;
|
||||
};
|
||||
|
||||
logging {
|
||||
channel default_log {
|
||||
file "named_iso8601";
|
||||
print-time iso8601;
|
||||
severity debug 9;
|
||||
};
|
||||
category default { default_log; default_debug; };
|
||||
};
|
||||
|
||||
controls {
|
||||
inet 127.0.0.1 port 9593
|
||||
allow { 127.0.0.1/32; ::1/128; }
|
||||
keys { "rndc-key"; };
|
||||
};
|
||||
|
||||
key "rndc-key" {
|
||||
algorithm hmac-sha256;
|
||||
secret "Am9vCg==";
|
||||
};
|
||||
|
||||
zone "." {
|
||||
type master;
|
||||
file "root.db";
|
||||
};
|
||||
46
bin/tests/system/logfileconfig/ns1/named.iso8601-utc
Normal file
46
bin/tests/system/logfileconfig/ns1/named.iso8601-utc
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2016 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
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
options {
|
||||
query-source address 10.53.0.1;
|
||||
notify-source 10.53.0.1;
|
||||
transfer-source 10.53.0.1;
|
||||
port 5300;
|
||||
pid-file "named.pid";
|
||||
listen-on port 5300 {
|
||||
10.53.0.1;
|
||||
};
|
||||
listen-on-v6 { none; };
|
||||
recursion no;
|
||||
notify yes;
|
||||
};
|
||||
|
||||
logging {
|
||||
channel default_log {
|
||||
file "named_iso8601_utc";
|
||||
print-time iso8601-utc;
|
||||
severity debug 9;
|
||||
};
|
||||
category default { default_log; default_debug; };
|
||||
};
|
||||
|
||||
controls {
|
||||
inet 127.0.0.1 port 9593
|
||||
allow { 127.0.0.1/32; ::1/128; }
|
||||
keys { "rndc-key"; };
|
||||
};
|
||||
|
||||
key "rndc-key" {
|
||||
algorithm hmac-sha256;
|
||||
secret "Am9vCg==";
|
||||
};
|
||||
|
||||
zone "." {
|
||||
type master;
|
||||
file "root.db";
|
||||
};
|
||||
@@ -12,16 +12,19 @@ SYSTEMTESTTOP=..
|
||||
. $SYSTEMTESTTOP/conf.sh
|
||||
THISDIR=`pwd`
|
||||
CONFDIR="ns1"
|
||||
PLAINCONF="${THISDIR}/${CONFDIR}/named.plain"
|
||||
DIRCONF="${THISDIR}/${CONFDIR}/named.dirconf"
|
||||
PIPECONF="${THISDIR}/${CONFDIR}/named.pipeconf"
|
||||
SYMCONF="${THISDIR}/${CONFDIR}/named.symconf"
|
||||
PLAINCONF="${THISDIR}/${CONFDIR}/named.plainconf"
|
||||
ISOCONF="${THISDIR}/${CONFDIR}/named.iso8601"
|
||||
ISOCONFUTC="${THISDIR}/${CONFDIR}/named.iso8601-utc"
|
||||
PLAINFILE="named_log"
|
||||
DIRFILE="named_dir"
|
||||
PIPEFILE="named_pipe"
|
||||
SYMFILE="named_sym"
|
||||
DLFILE="named_deflog"
|
||||
ISOFILE="named_iso8601"
|
||||
ISOUTCFILE="named_iso8601_utc"
|
||||
PIDFILE="${THISDIR}/${CONFDIR}/named.pid"
|
||||
myRNDC="$RNDC -c ${THISDIR}/${CONFDIR}/rndc.conf"
|
||||
myNAMED="$NAMED -c ${THISDIR}/${CONFDIR}/named.conf -m record,size,mctx -T clienttest -T nosyslog -d 99 -X named.lock -U 4"
|
||||
@@ -238,10 +241,8 @@ else
|
||||
echo "I: skipping symlink test (unable to create symlink)"
|
||||
fi
|
||||
|
||||
status=0
|
||||
|
||||
n=`expr $n + 1`
|
||||
echo "I:testing default logfile using named -L file ($n)"
|
||||
echo "I: testing default logfile using named -L file ($n)"
|
||||
# Now stop the server again and test the -L option
|
||||
rm -f $DLFILE
|
||||
$PERL ../../stop.pl .. ns1
|
||||
@@ -270,5 +271,29 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "I:testing logging functionality"
|
||||
|
||||
n=`expr $n + 1`
|
||||
echo "I: testing iso8601 timestamp ($n)"
|
||||
cp $ISOCONF named.conf
|
||||
$myRNDC reconfig > rndc.out.test$n 2>&1
|
||||
if grep '^....-..-..T..:..:..\.... ' $ISOFILE > /dev/null; then
|
||||
echo "I: testing iso8601 timestamp succeeded"
|
||||
else
|
||||
echo "I: testing iso8601 timestamp failed"
|
||||
status=`expr $status + 1`
|
||||
fi
|
||||
|
||||
n=`expr $n + 1`
|
||||
echo "I: testing iso8601-utc timestamp ($n)"
|
||||
cp $ISOCONFUTC named.conf
|
||||
$myRNDC reconfig > rndc.out.test$n 2>&1
|
||||
if grep '^....-..-..T..:..:..\....Z' $ISOUTCFILE > /dev/null; then
|
||||
echo "I: testing iso8601-utc timestamp succeeded"
|
||||
else
|
||||
echo "I: testing iso8601-utc timestamp failed"
|
||||
status=`expr $status + 1`
|
||||
fi
|
||||
|
||||
echo "I:exit status: $status"
|
||||
[ $status -eq 0 ] || exit 1
|
||||
|
||||
Reference in New Issue
Block a user