summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Echolot/Log.pm81
-rw-r--r--NEWS2
-rw-r--r--README7
-rw-r--r--UPGRADE5
-rw-r--r--debian/changelog1
-rw-r--r--debian/control2
-rwxr-xr-xtools/install-perl-modules2
7 files changed, 60 insertions, 40 deletions
diff --git a/Echolot/Log.pm b/Echolot/Log.pm
index 4c24aa0..7a04ec3 100644
--- a/Echolot/Log.pm
+++ b/Echolot/Log.pm
@@ -1,7 +1,7 @@
package Echolot::Log;
# (c) 2002 Peter Palfrader <peter@palfrader.org>
-# $Id: Log.pm,v 1.3 2003/01/14 06:32:22 weasel Exp $
+# $Id: Log.pm,v 1.4 2003/01/14 07:32:58 weasel Exp $
#
=pod
@@ -16,14 +16,26 @@ Echolot::Globals - echolot global variables
use strict;
use Carp qw{};
-use Log::Dispatch::File;
-use Log::Dispatch;
-my $LOG;
+my %LOGLEVELS = qw{
+ debug 7
+ info 6
+ notice 5
+ warn 4
+ warning 4
+ error 3
+ critical 2
+ alert 1
+ emergency 0
+};
+
+my $LOGLEVEL;
+my $LOGFILE;
+my $LOGFH;
my @monnames = qw{Jan Feb Mar Arp May Jun Jul Aug Sep Oct Nov Dec};
-sub header_log(%) {
- my (%msg) = @_;
+sub header_log($$) {
+ my ($level, $msg) = @_;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
my $time = sprintf("%s %02d %02d:%02d:%02d",
@@ -31,55 +43,70 @@ sub header_log(%) {
$mday,
$hour, $min, $sec);
my $logstring = $time.' '.
- '['.uc($msg{'level'}).']'. ' '.
- $msg{'message'}."\n";
+ '['.uc($level).']'. ' '.
+ $msg."\n";
$logstring =~ s/(?<=.)^/ /mg;
return $logstring;
};
sub reopen() {
- $LOG->remove( 'file1' );
- $LOG->add( Log::Dispatch::File->new(
- name => 'file1',
- min_level => Echolot::Config::get()->{'loglevel'},
- filename => Echolot::Config::get()->{'logfile'},
- mode => 'append',
- ));
+ $LOGFH->close() if ($LOGFH->opened());
+
+ open($LOGFH, ">>".$LOGFILE) or
+ warn("Cannot open logfile $LOGFILE: $!");
};
-sub init(%) {
- my (%args) = @_;
+sub init() {
+ $LOGFILE = Echolot::Config::get()->{'logfile'};
+ $LOGLEVEL = Echolot::Config::get()->{'loglevel'};
+ $LOGFH = new IO::Handle;
+
+ die ("Logfile not defined") unless defined ($LOGFILE);
+ die ("Loglevel not defined") unless defined ($LOGLEVEL);
+ die ("Loglevel $LOGLEVEL unkown") unless defined ($LOGLEVELS{$LOGLEVEL});
+
+ $LOGLEVEL = $LOGLEVELS{$LOGLEVEL};
- $LOG = Log::Dispatch->new( callbacks => \&header_log );
reopen();
};
+sub log_message($$) {
+ my ($level, $msg) = @_;
+
+ die("Loglevel $level unkown.") unless defined $LOGLEVELS{$level};
+ return if $LOGLEVELS{$level} > $LOGLEVEL;
+
+ $msg = header_log($level, $msg);
+ print $LOGFH $msg;
+ $LOGFH->flush();
+};
+
sub debug($) {
- $LOG->debug(@_);
+ log_message('debug', $_[0]);
};
sub info($) {
- $LOG->info(@_);
+ log_message('info', $_[0]);
};
sub notice($) {
- $LOG->notice(@_);
+ log_message('notice', $_[0]);
};
sub warn($) {
- $LOG->warning(@_);
+ log_message('warn', $_[0]);
};
sub warning($) {
- $LOG->warning(@_);
+ log_message('warning', $_[0]);
};
sub error($) {
- $LOG->error(@_);
+ log_message('error', $_[0]);
};
sub critical($) {
- $LOG->critical(@_);
+ log_message('critical', $_[0]);
};
sub alert($) {
- $LOG->alert(@_);
+ log_message('alert', $_[0]);
};
sub emergency($) {
- $LOG->emergency(@_);
+ log_message('emergency', $_[0]);
};
sub logdie($) {
diff --git a/NEWS b/NEWS
index 75579fd..3478a89 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,6 @@
Changes in version 2.0.9 - 2003-01-14
* Logging is finally cleaned up. There are two new config options:
- logfile and loglevel. Log::Dispatch is now required as well.
+ logfile and loglevel.
* Automatically remove stale .pid files.
Changes in version 2.0.8 - 2003-01-13
diff --git a/README b/README
index b5c4aa2..8711db2 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-$Id: README,v 1.38 2003/01/14 06:27:41 weasel Exp $
+$Id: README,v 1.39 2003/01/14 07:32:58 weasel Exp $
#####################################################################
## R E A D M E F O R E C H O L O T ###########################
#####################################################################
@@ -43,8 +43,6 @@ o HTML::Template
o GnuPG::Interface (0.33 or higher required)
o Data::Dumper (should be part of perl-base)
o Digest::MD5 (included in perl 5.8 or higher)
-o Log::Dispatch and
- Log::Dispatch::File (tested with 1.79 and 2.01)
INITIAL SETUP
-------------
@@ -72,8 +70,7 @@ o If the required perl modules above are not yet installed on your
On Debian for instance the following command can be used to get
everything that is required:
- # apt-get install liblog-dispatch-perl libgnupg-interface-perl
- libhtml-template-perl
+ # apt-get install libgnupg-interface-perl libhtml-template-perl
]
o Create a new user named »pinger« (You can use a different user name if
diff --git a/UPGRADE b/UPGRADE
index 2f83b59..1a52fe9 100644
--- a/UPGRADE
+++ b/UPGRADE
@@ -1,5 +1,5 @@
Upgrading checklist for Echolot
-$Id: UPGRADE,v 1.2 2003/01/14 06:27:41 weasel Exp $
+$Id: UPGRADE,v 1.3 2003/01/14 07:32:58 weasel Exp $
- Download the latest .tar.gz from <URL:http://www.palfrader.org/echolot/>.
- Verify the signature.
@@ -13,9 +13,6 @@ $Id: UPGRADE,v 1.2 2003/01/14 06:27:41 weasel Exp $
- Congratulations.
-Notes for upgrades from a version earlier than 2.0.9
- - The Log::Dispatch perl module is now required.
-
Notes for upgrades from a version earlier than 2.0.6
- If you have specified thesaurusindexfile and/or indexfilebasename in your
Echolot configuration file, please remove the .html extension from that
diff --git a/debian/changelog b/debian/changelog
index 07655bb..6ca9d69 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,7 +1,6 @@
echolot (2.0.9-1) unstable; urgency=medium
* New upstream version.
- Depends on liblog-dispatch-perl
* Remove link from output to /var/log/echolot/echolot.log
since pngd now has some sort of saner logging.
diff --git a/debian/control b/debian/control
index 729c8c5..5081c95 100644
--- a/debian/control
+++ b/debian/control
@@ -7,7 +7,7 @@ Standards-Version: 3.5.7
Package: echolot
Architecture: all
-Depends: ${shlibs:Depends}, debconf (>= 1.2.9), gnupg (>= 1.0.7), postfix | mail-transport-agent, mixmaster, libdigest-md5-perl, libhtml-template-perl, libgnupg-interface-perl (>= 0.33), liblog-dispatch-perl
+Depends: ${shlibs:Depends}, debconf (>= 1.2.9), gnupg (>= 1.0.7), postfix | mail-transport-agent, mixmaster, libdigest-md5-perl, libhtml-template-perl, libgnupg-interface-perl (>= 0.33)
Description: Pinger for anonymous remailers such as Mixmaster
A Pinger in the context of anonymous remailers is a program that
regularly sends messages through remailers to determine their status.
diff --git a/tools/install-perl-modules b/tools/install-perl-modules
index 2565bad..3848e8e 100755
--- a/tools/install-perl-modules
+++ b/tools/install-perl-modules
@@ -6,7 +6,7 @@
use strict;
use CPAN;
-for my $mod (qw{Data::Dumper Digest::MD5 HTML::Template GnuPG::Interface Log::Dispatch}) {
+for my $mod (qw{Data::Dumper Digest::MD5 HTML::Template GnuPG::Interface}) {
my $obj = CPAN::Shell->expand('Module',$mod);
$obj->install();
};