use File::Temp qw(tempfile);
use File::stat;
use Getopt::Long qw(:config gnu_getopt no_ignore_case);
-use POSIX qw(strftime WEXITSTATUS WIFEXITED);
use Pod::Usage;
our $VERSION = 1;
B<minc> adds all folders it filters into to this file, which is used
by lukem's B<new(1)> (XXX need a link).
-=item `mhpath +`/logs/minc.log
-
-Where B<minc> logs what it does, unless in -n mode.
-
=item `mhpath +`/.minc.context
B<minc> uses this file for context (i.e. current folder) instead of
$mh = `mhpath +`;
chomp($mh);
-my $logfile = $mh . '/logs/minc.log';
-
$ENV{"MHCONTEXT"} = $mh . '/.minc.context';
-\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'}});
-}
-
\f
###############################################################################
# Utility procedures
#sleep(2);
}
- mylog('+', $mhfolder);
-
if ($run) {
if (not rename($msg, $mhmsg)) {
die("rename($msg, $mhmsg): $!");
($msg eq '.' or $msg eq '..') and next;
my $headers = get_headers($msg);
- log_headers($headers);
undef($mhfolder);
for my $hook (@filter_hooks) {