Share

Postfix Admin

Subscribe

INFO level logging for vacation.pl

  1. 2009-09-18 14:27:28 UTC

    There seems to be almost no logging enabled by default at level info. I like to have something logged so it's possible to see later what did/didn't happen.

    To this end, I've edited vacation.pl :

    $ diff vacation.pl-orig vacation.pl

    261a262

    \> $logger->info("Notification interval elapsed, sending vacation reply: From: $from To:$to");

    274a276

    \> $logger->info("Already notified, not sending vacation reply (to: '$to', from: '$from')");

    376a379

    \> $logger->info("Sending vacation response (not previously notified) for $origmessageid: FROM: $email (origto: $origto), TO: $origfrom");

  2. 2009-09-18 14:29:00 UTC

    Oh yes, I also changed the log facility to mail in line 191.

  3. 2009-09-25 12:49:56 UTC

    Hi Simon,

    Any chance of getting that in 'diff -u' format - there isn't enough context around the lines you've given above for me to figure out whether it's worth merging or not

    thanks David.

  4. 2009-09-25 13:21:29 UTC
    diff -u vacation.pl-orig  vacation.pl
    --- vacation.pl-orig    2009-09-25 14:18:16.000000000 +0100
    +++ vacation.pl 2009-09-18 15:21:04.000000000 +0100
       @@ -188,7 +188,7 @@
         if($syslog == 1) {
             my $syslog_appender = Log::Log4perl::Appender->new(
                 'Log::Dispatch::Syslog',
    -            Facility => 'user',
    +            Facility => 'mail',
             );
             $logger->add_appender($syslog_appender);
         }
    @@ -259,6 +259,7 @@
                 my $int = $row[0];
                 if ($int > $interval) {
                     $logger->debug("[Interval elapsed, sending the message]: From: $from To:$to");
    +                $logger->info("Notification interval elapsed, sending vacation reply: From: $from To:$to");
                     $query = qq{UPDATE vacation_notification SET notified_at=NOW() WHERE on_vacation=? AND notified=?};
                     $stm = $dbh->prepare($query);
                     if (!$stm) {
    @@ -272,6 +273,7 @@
                     return 0;
                 } else {
                     $logger->debug("Notification interval not elapsed; not sending vacation reply (to: '$to', from: '$from')");
    +                $logger->info("Already notified, not sending vacation reply (to: '$to', from: '$from')");
                     return 1;
                 }
             } else {
    @@ -374,6 +376,7 @@
             }
    
             $logger->debug("Will send vacation response for $orig_messageid: FROM: $email (orig_to: $orig_to), TO: $orig_from; VACATION SUBJECT: $row[0] ; VACATION BODY: $row[1]");
    +        $logger->info("Sending vacation response (not previously notified) for $orig_messageid: FROM: $email (orig_to: $orig_to), TO: $orig_from");
             my $subject = $row[0];
             my $body = $row[1];
             my $from = $email;
    

    Not sure if that's the best format of logging, or if it should just be one log message in each place. I just wanted something in place quickly !

  5. 2009-09-26 08:18:06 UTC

    Why didn't you just change the reporting level, so the debug statements were logged?

    I've changed it so that stuff is reported to syslog's mail facility; not so sure about the other changes - they seem redundant.

  6. 2009-09-26 18:48:47 UTC

    Well the third one includes the whole message body in the log - a bit overkill for just an info level log. And the other two I wanted slightly different wording.

    I wasn't certain that debug included info - so I just duplicated the lines and edited them a bit. I won't be offended in the least if you do something totally different ;-)

    I guess the next bit will be to try and figure out how to add vacation to Logwatch - probably outside my very limited Perl abilities.

< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.