summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2003-01-14 06:40:24 +0000
committerPeter Palfrader <peter@palfrader.org>2003-01-14 06:40:24 +0000
commitde0bd086333426c994a97addfcdfc7365c14fdf7 (patch)
treed3a8a50bb4a834ad6e2cc702cf34f4c4fcfd417b
parente00e832d440e065e66858155264d0e79cfd3df23 (diff)
Make logging configureable
redirect stdout/err to the logfile rather than "outfile" (nothing should ever get there); redirect stderr to /dev/null when calling Mixmaster
-rw-r--r--Echolot/Config.pm9
-rw-r--r--Echolot/Pinger/Mix.pm4
-rw-r--r--doc/pingd.conf.pod23
-rwxr-xr-xpingd8
-rw-r--r--pingd.conf.sample5
5 files changed, 42 insertions, 7 deletions
diff --git a/Echolot/Config.pm b/Echolot/Config.pm
index 090d55b..385d1d4 100644
--- a/Echolot/Config.pm
+++ b/Echolot/Config.pm
@@ -1,7 +1,7 @@
package Echolot::Config;
# (c) 2002 Peter Palfrader <peter@palfrader.org>
-# $Id: Config.pm,v 1.45 2003/01/14 05:25:35 weasel Exp $
+# $Id: Config.pm,v 1.46 2003/01/14 06:40:24 weasel Exp $
#
=pod
@@ -138,6 +138,11 @@ sub init($) {
}
},
+ # logging
+ logfile => 'pingd.log',
+ loglevel => 'info',
+
+
# ping types
do_pings => {
'cpunk-dsa' => 1,
@@ -180,7 +185,7 @@ sub init($) {
" not a remailer\n".
"\n".
"If you want to talk to a human please mail <TMPL_VAR NAME=\"operator_address\">.\n",
-
+
homedir => undef,
my_localpart => undef,
my_domain => undef,
diff --git a/Echolot/Pinger/Mix.pm b/Echolot/Pinger/Mix.pm
index b0cf783..6e1072d 100644
--- a/Echolot/Pinger/Mix.pm
+++ b/Echolot/Pinger/Mix.pm
@@ -1,7 +1,7 @@
package Echolot::Pinger::Mix;
# (c) 2002 Peter Palfrader <peter@palfrader.org>
-# $Id: Mix.pm,v 1.11 2003/01/14 06:04:37 weasel Exp $
+# $Id: Mix.pm,v 1.12 2003/01/14 06:40:24 weasel Exp $
#
=pod
@@ -67,7 +67,7 @@ sub ping($$$$) {
return 0;
$ENV{'MIXPATH'} = Echolot::Config::get()->{'mixhome'};
- open(MIX, "|".Echolot::Config::get()->{'mixmaster'}." -m -S -l $chaincomma") or
+ open(MIX, "|".Echolot::Config::get()->{'mixmaster'}." -m -S -l $chaincomma 2>/dev/null") or
Echolot::Log::warn("Cannot exec mixpinger: $!."),
return 0;
print MIX "To: $to\n\n$body\n";
diff --git a/doc/pingd.conf.pod b/doc/pingd.conf.pod
index 2ba3d0f..a012b4f 100644
--- a/doc/pingd.conf.pod
+++ b/doc/pingd.conf.pod
@@ -514,6 +514,29 @@ generated stats. Otherwise its content is copied in verbatim.
=back
+=head2 LOGGING
+
+=over
+
+=item B<logfile>
+
+File to write logs to. This file is reopened on SIGHUP.
+
+ Default: 'logfile' => 'pingd.log',
+ Example: 'logfile' => '/var/log/echolot/pingd.log',
+
+=item B<loglevel>
+
+Minimum severity of messages to include in log file. Possible values are
+B<debug>, B<info>, B<notice>, B<warning>, B<error>, B<critical>, B<alert>, and
+B<emergency>.
+
+ Default: 'loglevel' => 'info',
+ Example: 'loglevel' => 'debug',
+
+=back
+
+
=head2 MISCELLANEOUS
=over
diff --git a/pingd b/pingd
index 361d889..7f7f858 100755
--- a/pingd
+++ b/pingd
@@ -3,7 +3,7 @@
$| = 1;
# (c) 2002 Peter Palfrader <peter@palfrader.org>
-# $Id: pingd,v 1.88 2003/01/14 06:27:41 weasel Exp $
+# $Id: pingd,v 1.89 2003/01/14 06:40:24 weasel Exp $
#
=pod
@@ -307,7 +307,8 @@ sub setSigHandlers() {
if ($redirected_stdio) {
close STDOUT;
close STDERR;
- open (STDOUT, ">>output") or die ("Cannot open 'output' as STDOUT\n");
+ my $logfile = Echolot::Config::get()->{'logfile'};
+ open (STDOUT, ">>$logfile") or die ("Cannot open '$logfile' as STDOUT\n");
open (STDERR, ">&STDOUT") or die ("Cannot dup STDOUT as STDERR\n");
};
Echolot::Log::reopen();
@@ -666,7 +667,8 @@ if ($COMMAND eq 'add' || $COMMAND eq 'delete') {
exit(0) if (fork());
POSIX::setsid();
exit(0) if (fork());
- open (STDOUT, ">>output") or die ("Cannot open 'output' as STDOUT\n");
+ my $logfile = Echolot::Config::get()->{'logfile'};
+ open (STDOUT, ">>$logfile") or die ("Cannot open '$logfile' as STDOUT\n");
open (STDERR, ">&STDOUT") or die ("Cannot dup STDOUT as STDERR\n");
open (STDIN , "</dev/null") or die ("Cannot open /dev/null as STDIN\n");
$redirected_stdio = 1;
diff --git a/pingd.conf.sample b/pingd.conf.sample
index b993b67..77cc781 100644
--- a/pingd.conf.sample
+++ b/pingd.conf.sample
@@ -42,5 +42,10 @@ $CONFIG = {
# standard format it is nice to read for a human eye.
'combined_list' => 0,
+ # Log file and level (valid levels are debug, info, notice, warning, error,
+ # critical, alert, emergency)
+ #'logfile' => 'pingd.log',
+ #'loglevel' => 'info',
+
};
1;