r24051 - in /branches/upstream/liblog-handler-perl/current: ./ examples/ lib/Log/ lib/Log/Handler/ lib/Log/Handler/Plugin/ lib/Log/Handler/Plugin/Config/
rmayorga-guest at users.alioth.debian.org
rmayorga-guest at users.alioth.debian.org
Sun Aug 10 05:25:51 UTC 2008
Author: rmayorga-guest
Date: Sun Aug 10 05:25:49 2008
New Revision: 24051
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=24051
Log:
[svn-upgrade] Integrating new upstream version, liblog-handler-perl (0.46)
Added:
branches/upstream/liblog-handler-perl/current/examples/example.props
branches/upstream/liblog-handler-perl/current/examples/example.yaml
Modified:
branches/upstream/liblog-handler-perl/current/ChangeLog
branches/upstream/liblog-handler-perl/current/MANIFEST
branches/upstream/liblog-handler-perl/current/META.yml
branches/upstream/liblog-handler-perl/current/README
branches/upstream/liblog-handler-perl/current/examples/benchmark.pl
branches/upstream/liblog-handler-perl/current/examples/example.conf
branches/upstream/liblog-handler-perl/current/examples/example.pl
branches/upstream/liblog-handler-perl/current/lib/Log/Handler.pm
branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Examples.pod
branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Output.pm
branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Plugin/Config/General.pm
branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Plugin/Config/Properties.pm
branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Plugin/YAML.pm
Modified: branches/upstream/liblog-handler-perl/current/ChangeLog
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/ChangeLog?rev=24051&op=diff
==============================================================================
--- branches/upstream/liblog-handler-perl/current/ChangeLog (original)
+++ branches/upstream/liblog-handler-perl/current/ChangeLog Sun Aug 10 05:25:49 2008
@@ -1,3 +1,7 @@
+0.45 Released at 2008-07-28.
+ - Fixed Plugin::YAML. It was created as Plugin::Config::YAML.
+ - Did some code/example improvements.
+
0.45 Released at 2008-07-25.
- Kicked $self->{caller_level} and replaced it with
Log::Handler::CALLER_LEVEL. The reason is that if dump(),
Modified: branches/upstream/liblog-handler-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/MANIFEST?rev=24051&op=diff
==============================================================================
--- branches/upstream/liblog-handler-perl/current/MANIFEST (original)
+++ branches/upstream/liblog-handler-perl/current/MANIFEST Sun Aug 10 05:25:49 2008
@@ -4,6 +4,8 @@
examples/client.pl
examples/example.conf
examples/example.pl
+examples/example.props
+examples/example.yaml
examples/layout.pl
examples/runtime.pl
examples/server.pl
Modified: branches/upstream/liblog-handler-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/META.yml?rev=24051&op=diff
==============================================================================
--- branches/upstream/liblog-handler-perl/current/META.yml (original)
+++ branches/upstream/liblog-handler-perl/current/META.yml Sun Aug 10 05:25:49 2008
@@ -1,6 +1,6 @@
---
name: Log-Handler
-version: 0.45
+version: 0.46
author:
- Jonny Schulz
abstract: Log messages to several outputs.
@@ -30,7 +30,7 @@
provides:
Log::Handler:
file: lib/Log/Handler.pm
- version: 0.45
+ version: 0.46
Log::Handler::Config:
file: lib/Log/Handler/Config.pm
version: 0.03
@@ -67,9 +67,9 @@
Log::Handler::Plugin::Config::Properties:
file: lib/Log/Handler/Plugin/Config/Properties.pm
version: 0.03
- Log::Handler::Plugin::Config::YAML:
+ Log::Handler::Plugin::YAML:
file: lib/Log/Handler/Plugin/YAML.pm
- version: 0.02
+ version: 0.03
generated_by: Module::Build version 0.2808
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.2.html
Modified: branches/upstream/liblog-handler-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/README?rev=24051&op=diff
==============================================================================
--- branches/upstream/liblog-handler-perl/current/README (original)
+++ branches/upstream/liblog-handler-perl/current/README Sun Aug 10 05:25:49 2008
@@ -328,7 +328,7 @@
would cause an error!
- "filter_caller"
+ filter_caller
You can use this option to set a package name. Only messages from
this packages will be logged.
@@ -694,7 +694,7 @@
$log->add(file => {
filename => 'file.log',
mode => 'append',
- message_layout => '%X %m %N',
+ message_layout => '%X %m%N',
});
Or use it with "message_pattern":
Modified: branches/upstream/liblog-handler-perl/current/examples/benchmark.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/examples/benchmark.pl?rev=24051&op=diff
==============================================================================
--- branches/upstream/liblog-handler-perl/current/examples/benchmark.pl (original)
+++ branches/upstream/liblog-handler-perl/current/examples/benchmark.pl Sun Aug 10 05:25:49 2008
@@ -44,7 +44,7 @@
$log->add(
forward => {
- alias => 'pattern',
+ alias => 'message pattern',
maxlevel => 'error',
minlevel => 'error',
newline => 1,
@@ -54,25 +54,53 @@
}
);
-my $count = 100_000;
-my $time = ();
+$log->add(
+ forward => {
+ alias => 'filter caller',
+ maxlevel => 'emerg',
+ minlevel => 'emerg',
+ newline => 1,
+ forward_to => \&buffer,
+ filter_caller => qr/^Foo::Bar\z/,
+ }
+);
-$time = timeit($count, sub { $log->info('foo') });
-print "$count loops for a complex output took: ", timestr($time) ,"\n";
-undef $BUFFER;
+$log->add(
+ forward => {
+ alias => 'filter message',
+ maxlevel => 'alert',
+ minlevel => 'alert',
+ newline => 1,
+ forward_to => \&buffer,
+ filter_message => qr/bar/,
+ }
+);
-$time = timeit($count, sub { $log->notice('foo') });
-print "$count loops for a simple output took: ", timestr($time) ,"\n";
-undef $BUFFER;
+my $count = 100_000;
+my $message = 'foo bar baz';
-$time = timeit($count, sub { $log->debug('foo') }); # debug will not be logged
-print "$count loops for a suppressed output took:", timestr($time) ,"\n";
-undef $BUFFER;
+run("simple pattern output took", $count, sub { $log->notice($message) } );
+run("default pattern output took", $count, sub { $log->warning($message) } );
+run("complex pattern output took", $count, sub { $log->info($message) } );
+run("message pattern output took", $count, sub { $log->error($message) } );
+run("suppressed output took", $count, sub { $log->debug($message) } );
+run("filtered caller output took", $count, \&Foo::Bar::emerg );
+run("suppressed caller output took", $count, \&Foo::Baz::emerg );
+run("filterd messages output took", $count, sub { $log->alert($message) } );
-$time = timeit($count, sub { $log->warning('foo') });
-print "$count loops for a default output took: ", timestr($time) ,"\n";
-undef $BUFFER;
+sub run {
+ my ($desc, $count, $bench) = @_;
+ my $time = timeit($count, $bench);
+ print sprintf('%-35s', $desc), ' : ', timestr($time), "\n";
+ undef $BUFFER;
+}
-$time = timeit($count, sub { $log->error('foo') });
-print "$count loops for a pattern output took: ", timestr($time) ,"\n";
-undef $BUFFER;
+# Filter messages by caller
+package Foo::Bar;
+sub emerg { $log->emerg($message) }
+
+# Suppressed messages by caller
+package Foo::Baz;
+sub emerg { $log->emerg($message) }
+
+1;
Modified: branches/upstream/liblog-handler-perl/current/examples/example.conf
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/examples/example.conf?rev=24051&op=diff
==============================================================================
--- branches/upstream/liblog-handler-perl/current/examples/example.conf (original)
+++ branches/upstream/liblog-handler-perl/current/examples/example.conf Sun Aug 10 05:25:49 2008
@@ -1,32 +1,8 @@
-<file>
- <default>
- newline = 1
- permissions = 0640
- timeformat = %b %d %H:%M:%S
- fileopen = 1
- reopen = 1
- mode = append
- message_layout = %T %H[%P] [%L] %S: %m
- debug_mode = 2
- </default>
- <common>
- filename = example-common-1.log
- maxlevel = info
- minlevel = warning
- </common>
- <error>
- filename = example-error-1.log
- maxlevel = warning
- minlevel = emergency
- </error>
- <debug>
- filename = example-debug-1.log
- maxlevel = debug
- minlevel = debug
- </debug>
-</file>
<screen>
- <dump_to_screen>
- dump = 1
- </dump_to_screen>
+ <screen1>
+ maxlevel = debug
+ minlevel = emerg
+ newline = 1
+ message_layout = %T %H[%P] [%L] Config::General - %m
+ </screen1>
</screen>
Modified: branches/upstream/liblog-handler-perl/current/examples/example.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/examples/example.pl?rev=24051&op=diff
==============================================================================
--- branches/upstream/liblog-handler-perl/current/examples/example.pl (original)
+++ branches/upstream/liblog-handler-perl/current/examples/example.pl Sun Aug 10 05:25:49 2008
@@ -6,9 +6,7 @@
my $log = Log::Handler->new();
$log->config(config => 'example.conf');
+$log->config(config => 'example.yaml');
+$log->config(config => 'example.props');
-$log->debug('debug message');
$log->info('info message');
-$log->warn('warn message');
-$log->crit('crit message');
-$log->fatal('fatal message');
Added: branches/upstream/liblog-handler-perl/current/examples/example.props
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/examples/example.props?rev=24051&op=file
==============================================================================
--- branches/upstream/liblog-handler-perl/current/examples/example.props (added)
+++ branches/upstream/liblog-handler-perl/current/examples/example.props Sun Aug 10 05:25:49 2008
@@ -1,0 +1,4 @@
+screen.screen2.maxlevel = debug
+screen.screen2.minlevel = emerg
+screen.screen2.newline = 1
+screen.screen2.message_layout = %T %H[%P] [%L] Config::Properties %m
Added: branches/upstream/liblog-handler-perl/current/examples/example.yaml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/examples/example.yaml?rev=24051&op=file
==============================================================================
--- branches/upstream/liblog-handler-perl/current/examples/example.yaml (added)
+++ branches/upstream/liblog-handler-perl/current/examples/example.yaml Sun Aug 10 05:25:49 2008
@@ -1,0 +1,7 @@
+---
+screen:
+ screen3:
+ maxlevel: debug
+ minlevel: emerg
+ newline: 1
+ message_layout: %T %H[%P] [%L] YAML - %m
Modified: branches/upstream/liblog-handler-perl/current/lib/Log/Handler.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/lib/Log/Handler.pm?rev=24051&op=diff
==============================================================================
--- branches/upstream/liblog-handler-perl/current/lib/Log/Handler.pm (original)
+++ branches/upstream/liblog-handler-perl/current/lib/Log/Handler.pm Sun Aug 10 05:25:49 2008
@@ -335,7 +335,7 @@
would cause an error!
-=item C<filter_caller>
+=item B<filter_caller>
You can use this option to set a package name. Only messages from this
packages will be logged.
@@ -729,7 +729,7 @@
$log->add(file => {
filename => 'file.log',
mode => 'append',
- message_layout => '%X %m %N',
+ message_layout => '%X %m%N',
});
Or use it with C<message_pattern>:
@@ -849,7 +849,7 @@
use Log::Handler::Pattern;
use base qw(Log::Handler::Levels);
-our $VERSION = '0.45';
+our $VERSION = '0.46';
our $ERRSTR = '';
# $TRACE and $CALLER_LEVEL are both used as global
@@ -899,7 +899,7 @@
# to iterate from minlevel to maxlevel and
# create an HoA with all active levels
-my @LEVEL_BY_NUM = qw(
+our @LEVEL_BY_NUM = qw(
EMERGENCY
ALERT
CRITICAL
@@ -1017,7 +1017,7 @@
my $pattern = shift;
# If no $name is set then we use $pattern as name
- my ($name, $proto) = @_ == 2 ? @_ : ($pattern, @_);
+ my ($name, $code) = @_ == 2 ? @_ : ($pattern, @_);
if ($pattern !~ /^%[a-ln-z]\z/i) {
Carp::croak "invalid pattern '$pattern'";
@@ -1030,8 +1030,8 @@
# Structure:
# $self->{pattern}->{'%X'}->{name} = 'name-of-x';
# $self->{pattern}->{'%X'}->{code} = 'value-of-x';
- $self->{pattern}->{$pattern}->{code} = $proto;
$self->{pattern}->{$pattern}->{name} = $name;
+ $self->{pattern}->{$pattern}->{code} = $code;
}
sub output {
@@ -1095,8 +1095,8 @@
debug_trace
die_on_errors
filter
+ filter_caller
filter_message
- filter_caller
maxlevel
message_layout
message_pattern
@@ -1160,9 +1160,10 @@
sub _validate_options {
my ($self, @args) = @_;
+ my (%wanted, $is_fatal);
my $pattern = $self->{pattern};
- my (%wanted, $is_fatal);
-
+
+ # Option 'filter' is deprecated.
if (exists $args[0]{filter}) {
$args[0]{filter_message} = delete $args[0]{filter};
}
@@ -1405,6 +1406,8 @@
Carp::croak "missing condition for paramater 'filter'";
}
+ # Remove all valid characters from the condition
+ # and check if invalid characters left.
my $cond = $filter{condition};
$cond =~ s/match\d+//g;
$cond =~ s/[()&|!<>=\s\d]+//;
Modified: branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Examples.pod
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Examples.pod?rev=24051&op=diff
==============================================================================
--- branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Examples.pod (original)
+++ branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Examples.pod Sun Aug 10 05:25:49 2008
@@ -1,6 +1,48 @@
=head1 NAME
-Log::Handler::Examples - Output examples.
+Log::Handler::Examples - Examples.
+
+=head1 ADD OUTPUTS
+
+ use Log::Handler;
+
+ my $log = Log::Handler->new();
+
+ $log->add( dbi => \%options );
+ $log->add( email => \%options );
+ $log->add( file => \%options );
+ $log->add( forward => \%options );
+ $log->add( screen => \%options );
+ $log->add( socket => \%options );
+
+This is the same like
+
+ $log->add( 'Log::Handler::Output::DBI' => \%options );
+ $log->add( 'Log::Handler::Output::Email' => \%options );
+ $log->add( 'Log::Handler::Output::File' => \%options );
+ $log->add( 'Log::Handler::Output::Forward' => \%options );
+ $log->add( 'Log::Handler::Output::Screen' => \%options );
+ $log->add( 'Log::Handler::Output::Socket' => \%options );
+
+You can add output objects on this way as well:
+
+ use Log::Handler;
+ use Log::Handler::Output::File;
+
+ my %file_options = (
+ filename => 'file1.log',
+ mode => 'append'
+ );
+
+ my %handler_options = (
+ maxlevel => 'info',
+ newline => 1
+ );
+
+ my $log = Log::Handler->new();
+ my $file = Log::Handler::Output::File->new( \%file_options );
+
+ $log->add( $file => \%handler_options );
=head1 LOG VIA DBI
@@ -293,7 +335,7 @@
reopen = 1
mode = append
debug_mode = 2
- message_layout = "%T %H[%P] [%L] %S: "
+ message_layout = %T %H[%P] [%L] %S: %m
</default>
<common>
Modified: branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Output.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Output.pm?rev=24051&op=diff
==============================================================================
--- branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Output.pm (original)
+++ branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Output.pm Sun Aug 10 05:25:49 2008
@@ -66,6 +66,9 @@
return 1 if $caller !~ $self->{filter_caller};
}
+ # The patterns must be generated for each output. The reason
+ # is that each output can have their own time/date format
+ # and the code which is executed can return another value.
foreach my $r (@{$self->{wanted_pattern}}) {
if (ref($r->{code})) {
$wanted->{$r->{name}} = &{$r->{code}}($self, $level);
Modified: branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Plugin/Config/General.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Plugin/Config/General.pm?rev=24051&op=diff
==============================================================================
--- branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Plugin/Config/General.pm (original)
+++ branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Plugin/Config/General.pm Sun Aug 10 05:25:49 2008
@@ -27,7 +27,7 @@
debug_mode = 2
filename = example.log
minlevel = warn
- message_layout = '%T %H[%P] [%L] %S: '
+ message_layout = %T %H[%P] [%L] %S: %m
newline = 1
</mylog>
</file>
Modified: branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Plugin/Config/Properties.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Plugin/Config/Properties.pm?rev=24051&op=diff
==============================================================================
--- branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Plugin/Config/Properties.pm (original)
+++ branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Plugin/Config/Properties.pm Sun Aug 10 05:25:49 2008
@@ -28,7 +28,7 @@
file.mylog.minlevel = warn
file.mylog.filename = example.log
file.mylog.newline = 1
- file.mylog.message_layout = '%T %H[%P] [%L] %S: '
+ file.mylog.message_layout = %T %H[%P] [%L] %S: %m
=head1 PREREQUISITES
Modified: branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Plugin/YAML.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Plugin/YAML.pm?rev=24051&op=diff
==============================================================================
--- branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Plugin/YAML.pm (original)
+++ branches/upstream/liblog-handler-perl/current/lib/Log/Handler/Plugin/YAML.pm Sun Aug 10 05:25:49 2008
@@ -1,12 +1,12 @@
=head1 NAME
-Log::Handler::Plugin::Config::YAML - Config loader for YAML.
+Log::Handler::Plugin::YAML - Config loader for YAML.
=head1 SYNOPSIS
- use Log::Handler::Plugin::Config::YAML;
+ use Log::Handler::Plugin::YAML;
- my $config = Log::Handler::Plugin::Config::YAML->get_config( $config_file );
+ my $config = Log::Handler::Plugin::YAML->get_config( $config_file );
=head1 ROUTINES
@@ -27,9 +27,9 @@
mode: append
newline: 1
permissions: 0640
- message_layout: '%T %H[%P] [%L] %S: '
+ message_layout: %T %H[%P] [%L] %S: %m
reopen: 1
- timeformat: '%b %d %H:%M:%S'
+ timeformat: %b %d %H:%M:%S
=head1 PREREQUISITES
@@ -58,13 +58,13 @@
=cut
-package Log::Handler::Plugin::Config::YAML;
+package Log::Handler::Plugin::YAML;
use strict;
use warnings;
use YAML;
-our $VERSION = '0.02';
+our $VERSION = '0.03';
sub get_config {
my ($class, $config_file) = @_;
More information about the Pkg-perl-cvs-commits
mailing list