From de0bd086333426c994a97addfcdfc7365c14fdf7 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Tue, 14 Jan 2003 06:40:24 +0000 Subject: 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 --- Echolot/Config.pm | 9 +++++++-- Echolot/Pinger/Mix.pm | 4 ++-- doc/pingd.conf.pod | 23 +++++++++++++++++++++++ pingd | 8 +++++--- pingd.conf.sample | 5 +++++ 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 -# $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 .\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 -# $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 + +File to write logs to. This file is reopened on SIGHUP. + + Default: 'logfile' => 'pingd.log', + Example: 'logfile' => '/var/log/echolot/pingd.log', + +=item B + +Minimum severity of messages to include in log file. Possible values are +B, B, B, B, B, B, B, and +B. + + 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 -# $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 , " 0, + # Log file and level (valid levels are debug, info, notice, warning, error, + # critical, alert, emergency) + #'logfile' => 'pingd.log', + #'loglevel' => 'info', + }; 1; -- cgit v1.2.3