adding timestamps to logging
This commit is contained in:
parent
eeb1854eec
commit
f29543dfff
|
@ -54,14 +54,14 @@ print STDOUT "register|ready\n";
|
||||||
while (my $line = <>) {
|
while (my $line = <>) {
|
||||||
next if ($line =~ m/^config/);
|
next if ($line =~ m/^config/);
|
||||||
chomp $line;
|
chomp $line;
|
||||||
print $fh "$line\n" if ($opt_v);
|
print $fh (scalar localtime() . " $line\n") if ($opt_v);
|
||||||
if ($line =~ m/^report/) {
|
if ($line =~ m/^report/) {
|
||||||
print $fh "$line\n" if ($opt_d);
|
print $fh (scalar localtime() . " $line\n") if ($opt_d);
|
||||||
my ($stream, $version, $timestamp, $subsystem, $event, $sid, $token, $code, $address) = split /\|/, $line;
|
my ($stream, $version, $timestamp, $subsystem, $event, $sid, $token, $code, $address) = split /\|/, $line;
|
||||||
if ($event eq "tx-mail" && $code eq "ok") {
|
if ($event eq "tx-mail" && $code eq "ok") {
|
||||||
$ooo{$sid} = 1;
|
$ooo{$sid} = 1;
|
||||||
$from = $address;
|
$from = $address;
|
||||||
print $fh "Virtual Vacation: created session $sid\n" if ($opt_d);
|
print $fh (scalar localtime() . " Virtual Vacation: created session $sid\n") if ($opt_d);
|
||||||
if ($from =~ m/^(postmaster|hostmaster|noreply|no-reply|bounce.*)@/i) { $ooo{$sid} = 0; }
|
if ($from =~ m/^(postmaster|hostmaster|noreply|no-reply|bounce.*)@/i) { $ooo{$sid} = 0; }
|
||||||
} elsif ($event eq "tx-mail" && $code ne "ok") {
|
} elsif ($event eq "tx-mail" && $code ne "ok") {
|
||||||
$ooo{$sid} = 0;
|
$ooo{$sid} = 0;
|
||||||
|
@ -70,7 +70,7 @@ while (my $line = <>) {
|
||||||
$email = $address;
|
$email = $address;
|
||||||
} elsif ($event eq "tx-rcpt" && $code ne "ok") {
|
} elsif ($event eq "tx-rcpt" && $code ne "ok") {
|
||||||
delete $ooo{$sid};
|
delete $ooo{$sid};
|
||||||
print $fh "Virtual Vacation: removed session $sid\n" if ($opt_d);
|
print $fh (scalar localtime() . " Virtual Vacation: removed session $sid\n") if ($opt_d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($line =~ m/^filter/) {
|
if ($line =~ m/^filter/) {
|
||||||
|
@ -83,18 +83,18 @@ while (my $line = <>) {
|
||||||
print STDOUT "filter-dataline|$sid|$token|$data\n";
|
print STDOUT "filter-dataline|$sid|$token|$data\n";
|
||||||
}
|
}
|
||||||
if ($line =~ m/data-line/ && $data eq '.' && $ooo{$sid} == 1) {
|
if ($line =~ m/data-line/ && $data eq '.' && $ooo{$sid} == 1) {
|
||||||
print $fh "Virtual Vacation: To: $email, From: $from\n" if ($opt_d);
|
print $fh (scalar localtime() . " Virtual Vacation: To: $email, From: $from\n") if ($opt_d);
|
||||||
my $query = qq{SELECT subject,body FROM vacation WHERE email='$email' and active=1};
|
my $query = qq{SELECT subject,body FROM vacation WHERE email='$email' and active=1};
|
||||||
my $sth = do_query($query);
|
my $sth = do_query($query);
|
||||||
my $rv = $sth->rows;
|
my $rv = $sth->rows;
|
||||||
if ($rv == 1) {
|
if ($rv == 1) {
|
||||||
print $fh "Virtual Vacation: Found OOO for $email\n" if ($opt_d);
|
print $fh (scalar localtime() . " Virtual Vacation: Found OOO for $email\n") if ($opt_d);
|
||||||
my @vacation_msg = $sth->fetchrow_array;
|
my @vacation_msg = $sth->fetchrow_array;
|
||||||
$query = qq{SELECT cache FROM vacation WHERE email='$email' AND FIND_IN_SET('$from',cache)};
|
$query = qq{SELECT cache FROM vacation WHERE email='$email' AND FIND_IN_SET('$from',cache)};
|
||||||
$sth = do_query($query);
|
$sth = do_query($query);
|
||||||
$rv = $sth->rows;
|
$rv = $sth->rows;
|
||||||
if ($rv == 0) {
|
if ($rv == 0) {
|
||||||
print $fh "Virtual Vacation: Sending OOO to $from\n" if ($opt_d);
|
print $fh (scalar localtime() . " Virtual Vacation: Sending OOO to $from\n") if ($opt_d);
|
||||||
$query = qq{UPDATE vacation SET cache=CONCAT(cache,',','$from') WHERE email='$email'};
|
$query = qq{UPDATE vacation SET cache=CONCAT(cache,',','$from') WHERE email='$email'};
|
||||||
$sth = do_query($query);
|
$sth = do_query($query);
|
||||||
open my $fh_email, "|-", "/usr/sbin/sendmail -t";
|
open my $fh_email, "|-", "/usr/sbin/sendmail -t";
|
||||||
|
@ -107,11 +107,11 @@ while (my $line = <>) {
|
||||||
close $fh_email;
|
close $fh_email;
|
||||||
}
|
}
|
||||||
delete $ooo{$sid};
|
delete $ooo{$sid};
|
||||||
print $fh "Virtual Vacation: removed session $sid\n" if ($opt_d);
|
print $fh (scalar localtime() . " Virtual Vacation: removed session $sid\n") if ($opt_d);
|
||||||
}
|
}
|
||||||
} elsif ($line =~ m/data-line/ && $data eq '.' && $ooo{$sid} == 0) {
|
} elsif ($line =~ m/data-line/ && $data eq '.' && $ooo{$sid} == 0) {
|
||||||
delete $ooo{$sid};
|
delete $ooo{$sid};
|
||||||
print $fh "Virtual Vacation: removed session $sid\n" if ($opt_d);
|
print $fh (scalar localtime() . " Virtual Vacation: removed session $sid\n") if ($opt_d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue