-\f
-###############################################################################
-# Logging
-
-sub mylog {
- $run or return;
-
- my $timestamp = strftime('%b %e %H:%M:%S', localtime);
- my $msg;
- foreach my $part (@_) {
- if (defined($part)) {
- $msg .= $part;
- }
- }
- # no newlines in the log message, thanks
- $msg =~ s/\n/ /gm;
-
- open(LOG, ">>$logfile") or die("open(>>$logfile): $!");
- print(LOG "$timestamp $msg\n") or die("print(>>$logfile): $!");
- close(LOG) or die("close($logfile): $!");
-}
-
-sub logheader {
- my ($text, @contents) = @_;
- my $last;
-
- if (@contents) {
- $last = $contents[-1];
- } else {
- $last = '';
- }
-
- mylog('<< ', $text, $last);
-}
-
-sub log_headers {
- my %headers = %{(shift)};
-
- # For an explanation of the %headers structure, see the
- # get_headers function below.
- logheader('From: ', @{$headers{'return-path'}});
- logheader('To: ', @{$headers{'to'}});
- logheader('Subject: ', @{$headers{'subject'}});
- logheader('Message-Id: ', @{$headers{'message-id'}});
-}
-