summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
cf3b28b)
Kill global constants LOG_DEBUGLEVEL, SCREEN_DEBUGLEVEL, DEBUGCHAR,
INFOCHAR, INCOMINGCHAR, SAVECHAR, WARNCHAR, ERRORCHAR.
Kill global $logger and functions logsave, loginfo, logdebug, logwarn,
logerr.
(mylog): Kill first two parameters; all @_ are now catenated for the
log message. Simply open $logfile and write the timestamp and
message, no more.
(logheader): Renamed from logincoming. Adapt to new mylog.
(log_headers): s/logincoming/logheader/
(store_message): Call mylog instead of logsave.
use FileHandle;
use File::stat;
use Getopt::Std; $Getopt::Std::STANDARD_HELP_VERSION = 1;
use FileHandle;
use File::stat;
use Getopt::Std; $Getopt::Std::STANDARD_HELP_VERSION = 1;
-use Log::Dispatch;
-use Log::Dispatch::File;
use POSIX qw(strftime WEXITSTATUS WIFEXITED);
our $VERSION = 1;
use POSIX qw(strftime WEXITSTATUS WIFEXITED);
our $VERSION = 1;
###############################################################################
# Logging
###############################################################################
# Logging
-# debuglevels for the logger
-use constant LOG_DEBUGLEVEL => 'info';
-use constant SCREEN_DEBUGLEVEL => 'debug';
-
-# characters used to wrap around the id field in the log so I can more
-# easily parse the msg flow
-use constant DEBUGCHAR => '%';
-use constant INFOCHAR => '=';
-use constant INCOMINGCHAR => '<';
-use constant SAVECHAR => '>';
-use constant WARNCHAR => 'W';
-use constant ERRORCHAR => 'E';
-
-my $logger = new Log::Dispatch;
-$logger->add(new Log::Dispatch::File (name=>'logfile',
- filename=>$logfile,
- min_level=>'info',
- mode=>'append'));
-
-# log alias, handles getting passed vars that are undef
- my $level = shift;
- my $act = shift;
my $timestamp = strftime('%b %e %H:%M:%S', localtime);
my $msg;
foreach my $part (@_) {
my $timestamp = strftime('%b %e %H:%M:%S', localtime);
my $msg;
foreach my $part (@_) {
}
# no newlines in the log message, thanks
$msg =~ s/\n/ /gm;
}
# no newlines in the log message, thanks
$msg =~ s/\n/ /gm;
- $msg = sprintf("%s %s%s %s\n", $timestamp, $act, $act, $msg);
- $logger->log(level=>$level, message=>$msg);
- if ($act eq SAVECHAR) {
- $logger->log(level=>$level, message=>"\n");
- }
+ open(LOG, ">>$logfile") or die("open(>>$logfile): $!");
+ print(LOG "$timestamp $msg\n") or die("print(>>$logfile): $!");
+ close(LOG) or die("close($logfile): $!");
-sub logsave { mylog('notice', SAVECHAR, @_); }
-sub loginfo { mylog('info', INFOCHAR, @_); }
-sub logdebug { mylog('debug', DEBUGCHAR, @_); }
-sub logwarn { mylog('warning', WARNCHAR, @_); }
-sub logerr { mylog('error', ERRORCHAR, @_); }
-
-sub logincoming {
my ($text, @contents) = @_;
my $last;
my ($text, @contents) = @_;
my $last;
- mylog('info', INCOMINGCHAR, $text, $last);
+ mylog('<< ', $text, $last);
# For an explanation of the %headers structure, see the
# get_headers function below.
# For an explanation of the %headers structure, see the
# get_headers function below.
- logincoming('From: ', @{$headers{'return-path'}});
- logincoming('To: ', @{$headers{'to'}});
- logincoming('Subject: ', @{$headers{'subject'}});
- logincoming('Message-Id: ', @{$headers{'message-id'}});
+ logheader('From: ', @{$headers{'return-path'}});
+ logheader('To: ', @{$headers{'to'}});
+ logheader('Subject: ', @{$headers{'subject'}});
+ logheader('Message-Id: ', @{$headers{'message-id'}});
}
if ($mhfolder ne 'SPAM') {
}
if ($mhfolder ne 'SPAM') {