Skip to content

Commit

Permalink
r30711@knight: rjbs | 2007-02-15 11:54:25 -0500
Browse files Browse the repository at this point in the history
 allow user to skip any logging
  • Loading branch information
rjbs committed Feb 15, 2007
1 parent fc58e0c commit 393e149
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
3 changes: 3 additions & 0 deletions Changes
@@ -1,5 +1,8 @@
Revision history for Perl extension Mail::Audit.

2.213 2007-02-15
add a no_log option

2.212 2006-10-31
try to avoid letting temp dirs linger too long

Expand Down
44 changes: 23 additions & 21 deletions lib/Mail/Audit.pm
Expand Up @@ -19,7 +19,7 @@ use constant REJECTED => 100;
use constant DEFERRED => 75;
use constant DELIVERED => 0;

$Mail::Audit::VERSION = '2.212';
$Mail::Audit::VERSION = '2.213';

=head1 NAME
Expand Down Expand Up @@ -158,31 +158,33 @@ sub new {

my $mime_test = (delete $opts{mime_test}) || $default_mime_test;

# set up logging
my $log = {};
$log->{fh} = Symbol::gensym;
$log->{level} = exists $opts{loglevel} ? $opts{loglevel} : 3;

$log->{file} = exists $opts{log}
? $opts{log}
: File::Spec->catfile(
File::Spec->tmpdir,
"$>-audit.log"
);

unless ($log->{file} and open $log->{fh}, ">>$log->{file}") {
warn "couldn't open $log->{file} to log" if $log->{file};
$log->{fh} = \*STDERR;
}

my $self = Mail::Audit::MailInternet->new(
(exists $opts{data} ? $opts{data} : \*STDIN),
Modify => 0
);

# This sucks, but the gut-construction order does, too. We need to make it
# saner in general. -- rjbs, 2006-06-04
$self->{_log} = $log;
# set up logging
unless ($opts{no_log}) {
my $log = {};
$log->{fh} = Symbol::gensym;
$log->{level} = exists $opts{loglevel} ? $opts{loglevel} : 3;

$log->{file} = exists $opts{log}
? $opts{log}
: File::Spec->catfile(
File::Spec->tmpdir,
"$>-audit.log"
);

unless ($log->{file} and open $log->{fh}, ">>$log->{file}") {
warn "couldn't open $log->{file} to log" if $log->{file};
$log->{fh} = \*STDERR;
}

# This sucks, but the gut-construction order does, too. We need to make it
# saner in general. -- rjbs, 2006-06-04
$self->{_log} = $log;
}

$self->_log(1, "------------------------------ new run at " . localtime);

Expand Down

0 comments on commit 393e149

Please sign in to comment.