Rene Schickbauer > Maplat-0.995 > Maplat::Helpers::MailLogger

Download:
Maplat-0.995.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.995   Source  

NAME ^

Maplat::Helpers::MailLogger - Logger on steroids

SYNOPSIS ^

  use Maplat::Helpers::MailLogger;
  
  my $logger = new Maplat::Helpers::MailLogger(
                file        => "tempfilename",
                subject     => "Automated mail for yada yada",
                server      => "mail.example.com",
                port        => 25,
                sender      => 'mytool@example.com',
                reciever    => 'user@example.com',
                debugdata   => 1
  );

  while($something) {
    ...
    if($error) {
      $logger->error($errortext);
    }
    ...
    # something *might* be wrong
    $logger->warn("Bistromatic drive needs recalibration");
    ...
    # Log some information
    $logger->info("Fuel level: $remainfuel");
    # and some debig info
    $logger->debug("Module foo has version $bar");
    ...
  }
  $logger->finish; # Finish up log and send it.

DESCRIPTION ^

This Module provides an easy way log information and send it as multipart mail with with a text log, CSV log attachment and a color-coded PDF version.

new

  my $logger = new Maplat::Helpers::MailLogger(
                file        => "tempfilename",
                subject     => "Automated mail for yada yada",
                server      => "mail.example.com",
                port        => 25,
                sender      => 'mytool@example.com',
                reciever    => 'user@example.com',
                debugdata   => 1
  );

Most options are self explaining (you might also see Mail::Sendmail for details). $file is the base filename used for the logfiles. $debugdata is a boolean and determines, if debug() lines are included in the mailed report.

start

Start logging.

debug

Takes one argument, a string. Logs this string with the level DEBUG.

info

Takes one argument, a string. Logs this string with the level INFO.

warning

Takes one argument, a string. Logs this string with the level WARNING.

error

Takes one argument, a string. Logs this string with the level ERROR.

finish

Finished up the report and sends it. It is prudent to discard the $logger object after a call to finish. Continuing to use the logger after a call to finish will not work and/or may have some undesired side effects.

logLine

Internal helper function.

makePDF

Internal helper function.

AUTHOR ^

Rene Schickbauer, <rene.schickbauer@gmail.com>

COPYRIGHT AND LICENSE ^

Copyright (C) 2008-2011 by Rene Schickbauer

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: