r26415 - in /trunk/liblog-handler-perl: Build.PL ChangeLog INSTALL META.yml debian/changelog debian/control lib/Log/Handler.pm lib/Log/Handler/Output/Email.pm t/017-handler-special-levels.t t/040-output-email.t

rmayorga-guest at users.alioth.debian.org rmayorga-guest at users.alioth.debian.org
Sat Nov 1 01:36:44 UTC 2008


Author: rmayorga-guest
Date: Sat Nov  1 01:36:41 2008
New Revision: 26415

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=26415
Log:
* New upstream release
* debian/control; add libemail-date-perl to B-D-I, this enable
  one more test. Also add it to Suggests

Modified:
    trunk/liblog-handler-perl/Build.PL
    trunk/liblog-handler-perl/ChangeLog
    trunk/liblog-handler-perl/INSTALL
    trunk/liblog-handler-perl/META.yml
    trunk/liblog-handler-perl/debian/changelog
    trunk/liblog-handler-perl/debian/control
    trunk/liblog-handler-perl/lib/Log/Handler.pm
    trunk/liblog-handler-perl/lib/Log/Handler/Output/Email.pm
    trunk/liblog-handler-perl/t/017-handler-special-levels.t
    trunk/liblog-handler-perl/t/040-output-email.t

Modified: trunk/liblog-handler-perl/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/Build.PL?rev=26415&op=diff
==============================================================================
--- trunk/liblog-handler-perl/Build.PL (original)
+++ trunk/liblog-handler-perl/Build.PL Sat Nov  1 01:36:41 2008
@@ -15,6 +15,7 @@
         'DBI'                => 0,
         'IO::Socket'         => 0,
         'Net::SMTP'          => 0,
+        'Email::Date'        => 0,
         'YAML'               => 0,
     },
     requires => {

Modified: trunk/liblog-handler-perl/ChangeLog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/ChangeLog?rev=26415&op=diff
==============================================================================
--- trunk/liblog-handler-perl/ChangeLog (original)
+++ trunk/liblog-handler-perl/ChangeLog Sat Nov  1 01:36:41 2008
@@ -1,3 +1,11 @@
+0.48    Released at 2008-10-28.
+        - Fixed a bug in Email.pm - no error message if a email
+          couldn't be send.
+        - Added Email::Date to send the date with a email.
+        - EMAIL: if the key $message->{level} exists then the level is
+          used in the subject: "$level: $subject". The level can
+          passed with the option message_pattern.
+
 0.47    Released at 2008-09-04.
         - Add new config features. Now it's possilbe to add the
           configuration for the outputs as a array reference.

Modified: trunk/liblog-handler-perl/INSTALL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/INSTALL?rev=26415&op=diff
==============================================================================
--- trunk/liblog-handler-perl/INSTALL (original)
+++ trunk/liblog-handler-perl/INSTALL Sat Nov  1 01:36:41 2008
@@ -4,7 +4,7 @@
    make
    make test
 
-"make test" do some tests. If you get failed messages then you shouldn't install the module.
+"make test" do some tests. If you get error messages then you shouldn't install the module.
 Otherwise your last step is:
 
    make install

Modified: trunk/liblog-handler-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/META.yml?rev=26415&op=diff
==============================================================================
--- trunk/liblog-handler-perl/META.yml (original)
+++ trunk/liblog-handler-perl/META.yml Sat Nov  1 01:36:41 2008
@@ -1,6 +1,6 @@
 ---
 name: Log-Handler
-version: 0.47
+version: 0.48
 author:
   - Jonny Schulz
 abstract: Log messages to several outputs.
@@ -24,13 +24,14 @@
   Config::General: 0
   Config::Properties: 0
   DBI: 0
+  Email::Date: 0
   IO::Socket: 0
   Net::SMTP: 0
   YAML: 0
 provides:
   Log::Handler:
     file: lib/Log/Handler.pm
-    version: 0.47
+    version: 0.48
   Log::Handler::Config:
     file: lib/Log/Handler/Config.pm
     version: 0.04
@@ -45,7 +46,7 @@
     version: 0.03
   Log::Handler::Output::Email:
     file: lib/Log/Handler/Output/Email.pm
-    version: 0.02
+    version: 0.03
   Log::Handler::Output::File:
     file: lib/Log/Handler/Output/File.pm
     version: 0.02

Modified: trunk/liblog-handler-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/debian/changelog?rev=26415&op=diff
==============================================================================
--- trunk/liblog-handler-perl/debian/changelog (original)
+++ trunk/liblog-handler-perl/debian/changelog Sat Nov  1 01:36:41 2008
@@ -1,3 +1,11 @@
+liblog-handler-perl (0.48-1) unstable; urgency=low
+
+  * New upstream release
+  * debian/control; add libemail-date-perl to B-D-I, this enable
+    one more test. Also add it to Suggests
+ 
+ -- Rene Mayorga <rmayorga at debian.org.sv>  Fri, 31 Oct 2008 19:24:49 -0600
+
 liblog-handler-perl (0.47-2) unstable; urgency=low
 
   * Add missing dependency on libuniversal-require-perl, thanks to Alexander

Modified: trunk/liblog-handler-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/debian/control?rev=26415&op=diff
==============================================================================
--- trunk/liblog-handler-perl/debian/control (original)
+++ trunk/liblog-handler-perl/debian/control Sat Nov  1 01:36:41 2008
@@ -4,7 +4,7 @@
 Build-Depends: debhelper (>= 7)
 Build-Depends-Indep: perl (>= 5.8.7), libtest-pod-perl,
  libtest-pod-coverage-perl, libparams-validate-perl, libdevel-backtrace-perl,
- libuniversal-require-perl, libdbi-perl
+ libuniversal-require-perl, libdbi-perl, libemail-date-perl
 Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
 Uploaders: Roberto C. Sanchez <roberto at connexer.com>,
  gregor herrmann <gregoa at debian.org>, Rene Mayorga <rmayorga at debian.org.sv>
@@ -17,7 +17,7 @@
 Architecture: all
 Depends: ${perl:Depends}, ${misc:Depends}, libparams-validate-perl,
  libdevel-backtrace-perl, libuniversal-require-perl
-Suggests: libconfig-general-perl, libyaml-perl, libdbi-perl
+Suggests: libconfig-general-perl, libyaml-perl, libdbi-perl, libemail-date-perl
 Description: A simple handler to log messages to a log file
  Log::Handler is just a simple object oriented log file handler and very easy to
  use.  It's possible to define a log level for your programs and control the

Modified: trunk/liblog-handler-perl/lib/Log/Handler.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/lib/Log/Handler.pm?rev=26415&op=diff
==============================================================================
--- trunk/liblog-handler-perl/lib/Log/Handler.pm (original)
+++ trunk/liblog-handler-perl/lib/Log/Handler.pm Sat Nov  1 01:36:41 2008
@@ -849,7 +849,7 @@
 use Log::Handler::Pattern;
 use base qw(Log::Handler::Levels);
 
-our $VERSION = '0.47';
+our $VERSION = '0.48';
 our $ERRSTR  = '';
 
 # $TRACE and $CALLER_LEVEL are both used as global

Modified: trunk/liblog-handler-perl/lib/Log/Handler/Output/Email.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/lib/Log/Handler/Output/Email.pm?rev=26415&op=diff
==============================================================================
--- trunk/liblog-handler-perl/lib/Log/Handler/Output/Email.pm (original)
+++ trunk/liblog-handler-perl/lib/Log/Handler/Output/Email.pm Sat Nov  1 01:36:41 2008
@@ -22,7 +22,7 @@
 =head1 DESCRIPTION
 
 With this output module it's possible to log messages via email and it used
-Net::SMTP to do it.
+Net::SMTP to do it. The date for the email is generated with C<Email::Date::format_date>.
 
 Net::SMTP is from Graham Barr and it does it's job very well.
 
@@ -129,6 +129,7 @@
 =head1 PREREQUISITES
 
     Carp
+    Email::Date
     Net::SMTP
     Params::Validate
 
@@ -162,8 +163,9 @@
 use Net::SMTP;
 use Params::Validate;
 use Carp;
-
-our $VERSION = '0.02';
+use Email::Date;
+
+our $VERSION = '0.03';
 our $ERRSTR  = '';
 our $TEST    =  0; # is needed to disable flush() for tests
 
@@ -178,11 +180,11 @@
     my $message = @_ > 1 ? {@_} : shift;
 
     if ($self->{buffer} == 0) {
-        $self->sendmail($message);
+        return $self->sendmail($message);
     }
 
     if (@{$self->{MESSAGE_BUFFER}} < $self->{buffer}) {
-        push @{$self->{MESSAGE_BUFFER}}, $message->{message};
+        push @{$self->{MESSAGE_BUFFER}}, $message;
     }
 
     if (@{$self->{MESSAGE_BUFFER}} == $self->{buffer}) {
@@ -193,23 +195,35 @@
 }
 
 sub flush {
-    my $self = shift;
+    my $self    = shift;
     my $message = ();
-
-    return 1 if $TEST || !@{$self->{MESSAGE_BUFFER}};
-
-    while (my $line = shift @{$self->{MESSAGE_BUFFER}}) {
-        $message .= $line;
-    }
-
-    return $self->sendmail(message => $message);
+    my $string  = '';
+
+    if ($TEST || !@{$self->{MESSAGE_BUFFER}}) {
+        return 1;
+    }
+
+    # Safe the last message to use the level for the subject
+    $message = pop @{$self->{MESSAGE_BUFFER}};
+
+    while (my $buffer = shift @{$self->{MESSAGE_BUFFER}}) {
+        $string .= $buffer->{message};
+    }
+
+    $message->{message} = $string . $message->{message};
+    return $self->sendmail($message);
 }
 
 sub sendmail {
     my $self    = shift;
     my $message = @_ > 1 ? {@_} : shift;
     my $subject = $message->{subject} || $self->{subject};
+    my $date    = Email::Date::format_date();
     my $smtp    = ();
+
+    if ($message->{level}) {
+        $subject = "$message->{level}: $subject";
+    }
 
     foreach my $host (@{$self->{host}}) {
         $smtp = Net::SMTP->new(
@@ -222,7 +236,7 @@
     }
 
     if (!$smtp) {
-        return $self->_raise_error("smtp error: unable to connect to any host");
+        return $self->_raise_error("smtp error: unable to connect to ".join(', ', @{$self->{host}}));
     }
 
     my $success = 0;
@@ -232,11 +246,12 @@
     $success++ if $smtp->datasend("From: $self->{from}\n");
     $success++ if $smtp->datasend("To: $self->{to}\n");
     $success++ if $smtp->datasend("Subject: $subject\n");
+    $success++ if $smtp->datasend("Date: $date\n");
     $success++ if $smtp->datasend($message->{message}."\n");
     $success++ if $smtp->dataend();
     $success++ if $smtp->quit();
 
-    if ($success != 9) {
+    if ($success != 10) {
         return $self->_raise_error("smtp error($success): unable to send mail to $self->{to}");
     }
 

Modified: trunk/liblog-handler-perl/t/017-handler-special-levels.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/t/017-handler-special-levels.t?rev=26415&op=diff
==============================================================================
--- trunk/liblog-handler-perl/t/017-handler-special-levels.t (original)
+++ trunk/liblog-handler-perl/t/017-handler-special-levels.t Sat Nov  1 01:36:41 2008
@@ -16,6 +16,7 @@
     EMERGENCY =>  2,
     FATAL     =>  1,
 );
+
 my @LEVELS = (qw/
     debug
     info

Modified: trunk/liblog-handler-perl/t/040-output-email.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/t/040-output-email.t?rev=26415&op=diff
==============================================================================
--- trunk/liblog-handler-perl/t/040-output-email.t (original)
+++ trunk/liblog-handler-perl/t/040-output-email.t Sat Nov  1 01:36:41 2008
@@ -6,6 +6,11 @@
     eval "use Net::SMTP;";
     if ($@) {
         plan skip_all => "No Net::SMTP installed";
+        exit(0);
+    } 
+    eval "use Email::Date;";
+    if ($@) {
+        plan skip_all => "No Email::Date installed";
         exit(0);
     } 
 };
@@ -19,7 +24,7 @@
     host     => [ 'bloonix.de' ],
     hello    => 'EHLO bloonix.de',
     timeout  => 60,
-    debug    => 1,
+    debug    => 0,
     from     => 'jschulz.cpan at bloonix.de',
     to       => 'jschulz.cpan at bloonix.de',
     subject  => 'Log::Handler::Output::Email test',
@@ -40,7 +45,7 @@
 
 foreach my $line ( @{$log->{MESSAGE_BUFFER}} ) {
     ++$all_lines;
-    next unless $line =~ /^test \d+$/;
+    next unless $line->{message} =~ /^test \d+$/;
     ++$match_lines;
 }
 




More information about the Pkg-perl-cvs-commits mailing list