r20723 - in /trunk/liblog-handler-perl: ./ debian/ examples/ lib/Log/ lib/Log/Handler/ lib/Log/Handler/Output/ t/
gregoa at users.alioth.debian.org
gregoa at users.alioth.debian.org
Thu Jun 5 16:34:10 UTC 2008
Author: gregoa
Date: Thu Jun 5 16:34:10 2008
New Revision: 20723
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=20723
Log:
New upstream release.
Removed:
trunk/liblog-handler-perl/examples/more-outputs.pl
Modified:
trunk/liblog-handler-perl/ChangeLog
trunk/liblog-handler-perl/MANIFEST
trunk/liblog-handler-perl/META.yml
trunk/liblog-handler-perl/README
trunk/liblog-handler-perl/debian/changelog
trunk/liblog-handler-perl/examples/layout.pl
trunk/liblog-handler-perl/examples/runtime.pl
trunk/liblog-handler-perl/lib/Log/Handler.pm
trunk/liblog-handler-perl/lib/Log/Handler/Output.pm
trunk/liblog-handler-perl/lib/Log/Handler/Output/DBI.pm
trunk/liblog-handler-perl/lib/Log/Handler/Pattern.pm
trunk/liblog-handler-perl/t/012-handler-message-pattern.t
Modified: trunk/liblog-handler-perl/ChangeLog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/ChangeLog?rev=20723&op=diff
==============================================================================
--- trunk/liblog-handler-perl/ChangeLog (original)
+++ trunk/liblog-handler-perl/ChangeLog Thu Jun 5 16:34:10 2008
@@ -1,3 +1,8 @@
+0.44 Released at 2008-06-04.
+ - Fixed set_pattern(). It dies if the key name is something like
+ 'x-name' because $m->{x-name} is not valid.
+ - Changed pattern %R to %r.
+
0.43 Released at 2008-05-21.
- Fixed log() in DBI.pm and Socket.pm - only try to reconnect
if persistent + reconnect is set to true. Sorry :(
Modified: trunk/liblog-handler-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/MANIFEST?rev=20723&op=diff
==============================================================================
--- trunk/liblog-handler-perl/MANIFEST (original)
+++ trunk/liblog-handler-perl/MANIFEST Thu Jun 5 16:34:10 2008
@@ -5,7 +5,6 @@
examples/example.conf
examples/example.pl
examples/layout.pl
-examples/more-outputs.pl
examples/runtime.pl
examples/server.pl
INSTALL
Modified: trunk/liblog-handler-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/META.yml?rev=20723&op=diff
==============================================================================
--- trunk/liblog-handler-perl/META.yml (original)
+++ trunk/liblog-handler-perl/META.yml Thu Jun 5 16:34:10 2008
@@ -1,9 +1,9 @@
---
name: Log-Handler
-version: 0.43
+version: 0.44
author:
- Jonny Schulz
-abstract: Log messages to one or more outputs.
+abstract: Log messages to several outputs.
license: perl
resources:
license: http://dev.perl.org/licenses/
@@ -30,7 +30,7 @@
provides:
Log::Handler:
file: lib/Log/Handler.pm
- version: 0.43
+ version: 0.44
Log::Handler::Config:
file: lib/Log/Handler/Config.pm
version: 0.03
@@ -39,7 +39,7 @@
version: 0.03
Log::Handler::Output:
file: lib/Log/Handler/Output.pm
- version: 0.02
+ version: 0.03
Log::Handler::Output::DBI:
file: lib/Log/Handler/Output/DBI.pm
version: 0.03
Modified: trunk/liblog-handler-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/README?rev=20723&op=diff
==============================================================================
--- trunk/liblog-handler-perl/README (original)
+++ trunk/liblog-handler-perl/README Thu Jun 5 16:34:10 2008
@@ -1,5 +1,5 @@
NAME
- Log::Handler - Log messages to one or more outputs.
+ Log::Handler - Log messages to several outputs.
SYNOPSIS
use Log::Handler;
@@ -17,10 +17,13 @@
$log->warning("a warinng here");
DESCRIPTION
- This module is just a simple object oriented log handler and very easy
- to use. It's possible to define a log level for your programs and
- control the amount of informations that will be logged to one or more
- outputs.
+ The "Log::Handler" is a object oriented handler for logging, tracing and
+ debugging. It is very easy to use and provides a simple interface for
+ multiple output objects with lots of configuration parameters. You can
+ easily filter the amount of logged information on a per-output base,
+ define priorities and create patterns to format the messages.
+
+ See the documentation for details.
LOG LEVELS
There are eigth levels available:
@@ -131,12 +134,12 @@
%H Hostname
%N Newline
%S Program name
- %R Runtime in seconds since program start
%C Caller - filename and line number
%p Caller - package name
%f Caller - file name
%l Caller - line number
%s Caller - subroutine name
+ %r Runtime in seconds since program start
%t Time measurement - replaced with the time since the last call of $level
%m Message
%% Procent
@@ -190,7 +193,7 @@
%P pid
%H hostname
%N newline
- %R runtime
+ %r runtime
%C caller
%p package
%f filename
@@ -651,11 +654,11 @@
set_pattern()
With this option you can set your own placeholders. Example:
- $log->set_pattern('%X', 'name', sub { 'value' });
+ $log->set_pattern('%X', 'key_name', sub { 'value' });
# or
- $log->set_pattern('%X', 'name', 'value');
+ $log->set_pattern('%X', 'key_name', 'value');
Then you can use this pattern in your message layout:
@@ -669,13 +672,15 @@
sub func {
my $m = shift;
- print "$m->{name} $m->{message}\n";
+ print "$m->{key_name} $m->{message}\n";
}
$log->add(forward => {
forward_to => \&func,
message_pattern => '%X %m',
});
+
+ Note: valid character for the key name are: "[%\w\-\.]+"
EXAMPLES
Log::Handler::Examples
Modified: trunk/liblog-handler-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/debian/changelog?rev=20723&op=diff
==============================================================================
--- trunk/liblog-handler-perl/debian/changelog (original)
+++ trunk/liblog-handler-perl/debian/changelog Thu Jun 5 16:34:10 2008
@@ -1,3 +1,9 @@
+liblog-handler-perl (0.44-1) UNRELEASED; urgency=low
+
+ * New upstream release.
+
+ -- gregor herrmann <gregoa at debian.org> Thu, 05 Jun 2008 18:33:03 +0200
+
liblog-handler-perl (0.43-1) unstable; urgency=low
* New upstream release.
Modified: trunk/liblog-handler-perl/examples/layout.pl
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/examples/layout.pl?rev=20723&op=diff
==============================================================================
--- trunk/liblog-handler-perl/examples/layout.pl (original)
+++ trunk/liblog-handler-perl/examples/layout.pl Thu Jun 5 16:34:10 2008
@@ -5,24 +5,27 @@
my $log = Log::Handler->new();
+$log->set_pattern('%x', 'x-name', 'x-value');
+
$log->add(
screen => {
message_layout =>
- 'level %L %N'.
- 'time %T %N'.
- 'date %D %N'.
- 'pid %P %N'.
- 'hostname %H %N'.
- 'runtime %R %N'.
- 'caller %C %N'.
- 'package %p %N'.
- 'filename %f %N'.
- 'line %l %N'.
- 'subroutine %s %N'.
- 'progname %S %N'.
- 'mtime %t %N'.
- 'message %m %N'.
- 'procent %% %N',
+ 'level %L%N'.
+ 'time %T%N'.
+ 'date %D%N'.
+ 'pid %P%N'.
+ 'hostname %H%N'.
+ 'caller %C%N'.
+ 'package %p%N'.
+ 'filename %f%N'.
+ 'line %l%N'.
+ 'subroutine %s%N'.
+ 'progname %S%N'.
+ 'runtime %r%N'.
+ 'mtime %t%N'.
+ 'message %m%N'.
+ 'procent %%%N'.
+ 'x-name %x%N',
}
);
Modified: trunk/liblog-handler-perl/examples/runtime.pl
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/examples/runtime.pl?rev=20723&op=diff
==============================================================================
--- trunk/liblog-handler-perl/examples/runtime.pl (original)
+++ trunk/liblog-handler-perl/examples/runtime.pl Thu Jun 5 16:34:10 2008
@@ -8,7 +8,7 @@
$log->add(
screen => {
maxlevel => 'debug',
- message_layout => '%T %L %m runtime: %t, total runtime: %R %N',
+ message_layout => '%T %L %m runtime: %t, total runtime: %r%N',
}
);
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=20723&op=diff
==============================================================================
--- trunk/liblog-handler-perl/lib/Log/Handler.pm (original)
+++ trunk/liblog-handler-perl/lib/Log/Handler.pm Thu Jun 5 16:34:10 2008
@@ -1,6 +1,6 @@
=head1 NAME
-Log::Handler - Log messages to one or more outputs.
+Log::Handler - Log messages to several outputs.
=head1 SYNOPSIS
@@ -20,9 +20,13 @@
=head1 DESCRIPTION
-This module is just a simple object oriented log handler and very easy to use.
-It's possible to define a log level for your programs and control the amount
-of informations that will be logged to one or more outputs.
+The C<Log::Handler> is a object oriented handler for logging, tracing and
+debugging. It is very easy to use and provides a simple interface for
+multiple output objects with lots of configuration parameters. You can
+easily filter the amount of logged information on a per-output base,
+define priorities and create patterns to format the messages.
+
+See the documentation for details.
=head1 LOG LEVELS
@@ -39,7 +43,8 @@
C<debug> is the highest and C<emergency> is the lowest level.
-Level C<debug> is the highest level because it basically says to log every peep.
+Level C<debug> is the highest level because it basically says to log
+every peep.
=head1 METHODS
@@ -137,12 +142,12 @@
%H Hostname
%N Newline
%S Program name
- %R Runtime in seconds since program start
%C Caller - filename and line number
%p Caller - package name
%f Caller - file name
%l Caller - line number
%s Caller - subroutine name
+ %r Runtime in seconds since program start
%t Time measurement - replaced with the time since the last call of $level
%m Message
%% Procent
@@ -196,7 +201,7 @@
%P pid
%H hostname
%N newline
- %R runtime
+ %r runtime
%C caller
%p package
%f filename
@@ -683,11 +688,11 @@
With this option you can set your own placeholders. Example:
- $log->set_pattern('%X', 'name', sub { 'value' });
+ $log->set_pattern('%X', 'key_name', sub { 'value' });
# or
- $log->set_pattern('%X', 'name', 'value');
+ $log->set_pattern('%X', 'key_name', 'value');
Then you can use this pattern in your message layout:
@@ -701,13 +706,15 @@
sub func {
my $m = shift;
- print "$m->{name} $m->{message}\n";
+ print "$m->{key_name} $m->{message}\n";
}
$log->add(forward => {
forward_to => \&func,
message_pattern => '%X %m',
});
+
+Note: valid character for the key name are: C<[%\w\-\.]+>
=head1 EXAMPLES
@@ -812,7 +819,7 @@
use Log::Handler::Pattern;
use base qw(Log::Handler::Levels);
-our $VERSION = '0.43';
+our $VERSION = '0.44';
our $ERRSTR = '';
# turn on/off tracing
@@ -897,7 +904,7 @@
}
sub add {
- @_ == 3 or Carp::croak 'Usage: add( $output => \%options )';
+ @_ == 3 or Carp::croak 'Usage: $log->add( $output => \%options )';
my $self = shift;
my $output = $self->_new_output(@_);
my $levels = $self->{levels};
@@ -946,6 +953,7 @@
}
sub config {
+ @_ > 1 or Carp::croak 'Usage: $log->config( %param )';
my $self = shift;
my $configs = Log::Handler::Config->config(@_);
@@ -963,14 +971,20 @@
}
sub set_pattern {
- @_ == 4 or Carp::croak 'Usage: $log->set_pattern( $pattern, $name, $code )';
- my ($self, $pattern, $name, $proto) = @_;
+ (@_ == 3 || @_ == 4)
+ or Carp::croak 'Usage: $log->set_pattern( $pattern, $name, $code )';
+
+ my $self = shift;
+ my $pattern = shift;
+
+ # If no $name is set then we use $pattern as name
+ my ($name, $proto) = @_ == 2 ? @_ : ($pattern, @_);
if ($pattern !~ /^%[a-ln-z]\z/i) {
Carp::croak "invalid pattern '$pattern'";
}
- if (ref($name) || !length($name)) {
+ if (!defined $name || $name !~ /^[%\w\-\.]+\z/) {
Carp::croak "invalid/missing name for pattern '$pattern'";
}
@@ -982,8 +996,8 @@
}
sub output {
+ @_ == 2 or Carp::croak 'Usage: $log->output( $alias )';
my ($self, $name) = @_;
- return unless length($name);
my $alias = $self->{alias};
return exists $alias->{$name} ? $alias->{$name}->{output} : undef;
}
@@ -1248,12 +1262,12 @@
#
# sub {
# my ($w, $m) = @_; # %wanted pattern, %message
- # $m->{message} =
- # $w->{time}
+ # $m->{'message'} =
+ # $w->{'time'}
# . ' ['
- # . $w->{level}
+ # . $w->{'level'}
# . '] '
- # . $w->{message}
+ # . $w->{'message'}
# );
# }
@@ -1262,7 +1276,7 @@
if ( exists $pattern->{$p} ) {
$wanted{$p} = undef;
my $name = $pattern->{$p}->{name};
- push @chunks, "\$w->{$name}";
+ push @chunks, "\$w->{'$name'}";
} else {
# quote backslash and apostrophe
$p =~ s/\\/\\\\/g;
Modified: trunk/liblog-handler-perl/lib/Log/Handler/Output.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/lib/Log/Handler/Output.pm?rev=20723&op=diff
==============================================================================
--- trunk/liblog-handler-perl/lib/Log/Handler/Output.pm (original)
+++ trunk/liblog-handler-perl/lib/Log/Handler/Output.pm Thu Jun 5 16:34:10 2008
@@ -39,12 +39,12 @@
use strict;
use warnings;
-our $VERSION = '0.02';
-our $ERRSTR = '';
-
use Carp;
use UNIVERSAL;
use Devel::Backtrace;
+
+our $VERSION = '0.03';
+our $ERRSTR = '';
sub new {
my ($class, $options, $output) = @_;
Modified: trunk/liblog-handler-perl/lib/Log/Handler/Output/DBI.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/lib/Log/Handler/Output/DBI.pm?rev=20723&op=diff
==============================================================================
--- trunk/liblog-handler-perl/lib/Log/Handler/Output/DBI.pm (original)
+++ trunk/liblog-handler-perl/lib/Log/Handler/Output/DBI.pm Thu Jun 5 16:34:10 2008
@@ -133,13 +133,13 @@
%P pid
%H hostname
%N newline
- %R runtime
%C caller
%p package
%f filename
%l line
%s subroutine
%S progname
+ %r runtime
%t mtime
%m message
@@ -294,7 +294,7 @@
if ($self->{persistent} && $self->{reconnect}) {
warn "ping the database" if $self->{debug};
- # if the database is reachable than it might be an error with
+ # if the database is reachable then it might be an error with
# the statemant or values
if ($self->{dbh}->ping) {
return $self->_raise_error("DBI execute error: $execute_error");
Modified: trunk/liblog-handler-perl/lib/Log/Handler/Pattern.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/lib/Log/Handler/Pattern.pm?rev=20723&op=diff
==============================================================================
--- trunk/liblog-handler-perl/lib/Log/Handler/Pattern.pm (original)
+++ trunk/liblog-handler-perl/lib/Log/Handler/Pattern.pm Thu Jun 5 16:34:10 2008
@@ -59,11 +59,11 @@
code => \&Sys::Hostname::hostname },
'%N' => { name => 'newline',
code => "\n" },
+ '%S' => { name => 'progname',
+ code => $progname },
'%C' => { name => 'caller',
code => \&_get_caller },
- '%S' => { name => 'progname',
- code => $progname },
- '%R' => { name => 'runtime',
+ '%r' => { name => 'runtime',
code => \&_get_runtime },
'%t' => { name => 'mtime',
code => \&_get_hires },
Modified: trunk/liblog-handler-perl/t/012-handler-message-pattern.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/liblog-handler-perl/t/012-handler-message-pattern.t?rev=20723&op=diff
==============================================================================
--- trunk/liblog-handler-perl/t/012-handler-message-pattern.t (original)
+++ trunk/liblog-handler-perl/t/012-handler-message-pattern.t Thu Jun 5 16:34:10 2008
@@ -10,13 +10,13 @@
'%D' => 'date',
'%P' => 'pid',
'%H' => 'hostname',
- '%R' => 'runtime',
'%C' => 'caller',
'%p' => 'package',
'%f' => 'filename',
'%l' => 'line',
'%s' => 'subroutine',
'%S' => 'progname',
+ '%r' => 'runtime',
'%t' => 'mtime',
'%m' => 'message',
);
More information about the Pkg-perl-cvs-commits
mailing list