Hello community,
here is the log from the commit of package perl-Log-Log4perl
checked in at Mon Sep 8 18:12:02 CEST 2008.
--------
--- perl-Log-Log4perl/perl-Log-Log4perl.changes 2008-04-04 11:23:04.000000000 +0200
+++ /mounts/work_src_done/STABLE/perl-Log-Log4perl/perl-Log-Log4perl.changes 2008-09-05 16:14:08.934734000 +0200
@@ -1,0 +2,37 @@
+Fri Sep 5 16:12:29 CEST 2008 - ug@suse.de
+
+* Added explanation that categories and loggers are the same
+ thing (thanks to Rabbit).
+* Fixed t/053Resurrect to work with 5.005_03
+* Added preinit_callback function for init_and_watch()
+* Applied patch by Andy Grundman which speeds up is_LEVEL()
+ calls by skipping unnecessary string concatenations
+ (http://rt.cpan.org/Ticket/Display.html?id=38537).
+* Applied patch by Jae Gangemi addding a no_warning option to the
+ socket appender
+ (http://rt.cpan.org/Ticket/Display.html?id=34399).
+* Fixed test suite to run on Strawberry Perl on Win32.
+* Added 'l4p' as a valid prefix in configuration files (equal
+ to 'log4j' and 'log4perl' now).
+* Changed appender destruction during cleanup to show warning
+ messages thrown by destructors. Previously L4p ignored these
+ messages which caused failed DB flushes to go unnoticed with
+ the DB appender.
+* Added explanation for Log4perl messages during global
+ destruction to FAQ.
+* Corrected 'Trapper' listing in FAQ, thanks to Christian Reiber.
+* Applied patch by Mitchell Perilstein for 5.005it and the
+ two-argument binmode() that 5.005 doesn't support.
+ (http://rt.cpan.org/Ticket/Display.html?id=34051)
+* Applied patch by Emmanuel Rodriguez (POTYL) doing away with
+ hard-coded line numbers in 024WarnDieCarp.t to make it work
+ cpan2rpm for building RPM packages
+ (http://rt.cpan.org/Public/Bug/Display.html?id=35370)
+* Fixed recreate_check_interval = 0 bug reported by
+ Bill Moseley.
+* Added 'header_text' parameter to the file appender to
+ have it write a header every time it opens (or re-opens)
+ a new log file (suggested by Steven Lembark).
+* version 1.18
+
+-------------------------------------------------------------------
Old:
----
Log-Log4perl-1.15.tar.gz
New:
----
Log-Log4perl-1.18.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-Log-Log4perl.spec ++++++
--- /var/tmp/diff_new_pack.Q25707/_old 2008-09-08 18:11:49.000000000 +0200
+++ /var/tmp/diff_new_pack.Q25707/_new 2008-09-08 18:11:49.000000000 +0200
@@ -1,10 +1,17 @@
#
-# spec file for package perl-Log-Log4perl (Version 1.15)
+# spec file for package perl-Log-Log4perl (Version 1.18)
#
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
-# This file and all modifications and additions to the pristine
-# package are under the same license as the package itself.
#
+# All modifications and additions to the file contributed by third parties
+# remain the property of their copyright owners, unless otherwise agreed
+# upon. The license for this file, and modifications and additions to the
+# file, is the same license as for the pristine package itself (unless the
+# license for the pristine package is not an Open Source License, in which
+# case the license is the MIT License). An "Open Source License" is a
+# license that conforms to the Open Source Definition (Version 1.9)
+# published by the Open Source Initiative.
+
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
@@ -17,7 +24,7 @@
#Requires:
AutoReqProv: on
Summary: Log4j implementation for Perl
-Version: 1.15
+Version: 1.18
Release: 1
Source: Log-Log4perl-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@@ -78,6 +85,40 @@
%doc %{_mandir}/man3/*
%changelog
+* Fri Sep 05 2008 ug@suse.de
+ * Added explanation that categories and loggers are the same
+ thing (thanks to Rabbit).
+ * Fixed t/053Resurrect to work with 5.005_03
+ * Added preinit_callback function for init_and_watch()
+ * Applied patch by Andy Grundman which speeds up is_LEVEL()
+ calls by skipping unnecessary string concatenations
+ (http://rt.cpan.org/Ticket/Display.html?id=38537).
+ * Applied patch by Jae Gangemi addding a no_warning option to the
+ socket appender
+ (http://rt.cpan.org/Ticket/Display.html?id=34399).
+ * Fixed test suite to run on Strawberry Perl on Win32.
+ * Added 'l4p' as a valid prefix in configuration files (equal
+ to 'log4j' and 'log4perl' now).
+ * Changed appender destruction during cleanup to show warning
+ messages thrown by destructors. Previously L4p ignored these
+ messages which caused failed DB flushes to go unnoticed with
+ the DB appender.
+ * Added explanation for Log4perl messages during global
+ destruction to FAQ.
+ * Corrected 'Trapper' listing in FAQ, thanks to Christian Reiber.
+ * Applied patch by Mitchell Perilstein for 5.005it and the
+ two-argument binmode() that 5.005 doesn't support.
+ (http://rt.cpan.org/Ticket/Display.html?id=34051)
+ * Applied patch by Emmanuel Rodriguez (POTYL) doing away with
+ hard-coded line numbers in 024WarnDieCarp.t to make it work
+ cpan2rpm for building RPM packages
+ (http://rt.cpan.org/Public/Bug/Display.html?id=35370)
+ * Fixed recreate_check_interval = 0 bug reported by
+ Bill Moseley.
+ * Added 'header_text' parameter to the file appender to
+ have it write a header every time it opens (or re-opens)
+ a new log file (suggested by Steven Lembark).
+ * version 1.18
* Fri Apr 04 2008 ug@suse.de
- version update from 1.12 to 1.15
- appender_thresholds_adjust() with a parameter of 0 now
++++++ Log-Log4perl-1.15.tar.gz -> Log-Log4perl-1.18.tar.gz ++++++
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/Changes new/Log-Log4perl-1.18/Changes
--- old/Log-Log4perl-1.15/Changes 2008-02-10 09:04:38.000000000 +0100
+++ new/Log-Log4perl-1.18/Changes 2008-08-24 08:06:10.000000000 +0200
@@ -2,6 +2,44 @@
Revision history for Log::Log4perl
##################################################
+1.18 (2008/08/23)
+ * (ms) Added explanation that categories and loggers are the same
+ thing (thanks to Rabbit).
+ * (ms) Fixed t/053Resurrect to work with 5.005_03
+ * (ms) Added preinit_callback function for init_and_watch()
+ * (ms) Applied patch by Andy Grundman which speeds up is_LEVEL()
+ calls by skipping unnecessary string concatenations
+ (http://rt.cpan.org/Ticket/Display.html?id=38537).
+ * (ms) Applied patch by Jae Gangemi addding a no_warning option to the
+ socket appender
+ (http://rt.cpan.org/Ticket/Display.html?id=34399).
+
+1.17 (2008/07/19)
+ * (ms) Fixed test suite to run on Strawberry Perl on Win32.
+ * (ms) Added 'l4p' as a valid prefix in configuration files (equal
+ to 'log4j' and 'log4perl' now).
+
+1.16 (2008/05/15)
+ * (ms) Changed appender destruction during cleanup to show warning
+ messages thrown by destructors. Previously L4p ignored these
+ messages which caused failed DB flushes to go unnoticed with
+ the DB appender.
+ * (ms) Added explanation for Log4perl messages during global
+ destruction to FAQ.
+ * (ms) Corrected 'Trapper' listing in FAQ, thanks to Christian Reiber.
+ * (ms) Applied patch by Mitchell Perilstein for 5.005it and the
+ two-argument binmode() that 5.005 doesn't support.
+ (http://rt.cpan.org/Ticket/Display.html?id=34051)
+ * (ms) Applied patch by Emmanuel Rodriguez (POTYL) doing away with
+ hard-coded line numbers in 024WarnDieCarp.t to make it work
+ cpan2rpm for building RPM packages
+ (http://rt.cpan.org/Public/Bug/Display.html?id=35370)
+ * (ms) Fixed recreate_check_interval = 0 bug reported by
+ Bill Moseley.
+ * (ms) Added 'header_text' parameter to the file appender to
+ have it write a header every time it opens (or re-opens)
+ a new log file (suggested by Steven Lembark).
+
1.15 (2008/02/10)
* (ms) appender_thresholds_adjust() with a parameter of 0 now
does nothing (requested by Oliver Koch).
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/eg/5005it.pl new/Log-Log4perl-1.18/eg/5005it.pl
--- old/Log-Log4perl-1.15/eg/5005it.pl 2004-07-04 19:42:28.000000000 +0200
+++ new/Log-Log4perl-1.18/eg/5005it.pl 2008-03-16 05:48:09.000000000 +0100
@@ -48,6 +48,10 @@
# 5.00503 can't handle constants that start with a _
$data =~ s/_INTERNAL_DEBUG/INTERNAL_DEBUG/g;
+ # Anything before 5.6.0 doesn't have the two argument binmode.
+ # Convert to one arg version by discarding second arg.
+ $data =~ s{ binmode \s* \(? (.*?) , .* \)? \s* ; }{ "binmode $1 ;" }gex;
+
open FILE, ">$file" or die "Cannot open $file";
print FILE $data;
close FILE;
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/eg/benchmarks/simple new/Log-Log4perl-1.18/eg/benchmarks/simple
--- old/Log-Log4perl-1.15/eg/benchmarks/simple 1970-01-01 01:00:00.000000000 +0100
+++ new/Log-Log4perl-1.18/eg/benchmarks/simple 2008-07-08 15:51:04.000000000 +0200
@@ -0,0 +1,66 @@
+#!/usr/local/bin/perl -w
+###########################################
+# Log4perl Benchmarks
+# Mike Schilli, 2008 (m@perlmeister.com)
+###########################################
+use strict;
+use Benchmark qw(timeit timestr);
+use Log::Log4perl qw(:easy);
+use Data::Dumper;
+
+my $nof_tests = 100000;
+
+test_init("DEBUG");
+run("DEBUG-debug", \&debug_logger);
+
+test_init("ERROR");
+run("ERROR-debug", \&debug_logger);
+
+test_init("DEBUG");
+run("DEBUG-debug (subcat)", \&subcat_logger);
+
+test_init("ERROR");
+run("ERROR-debug (subcat)", \&subcat_logger);
+
+###########################################
+sub run {
+###########################################
+ my($name, $sub) = @_;
+
+ my $t = timeit(1, $sub);
+ printf "$name: %.1f per sec\n", $nof_tests/$t->[1];
+}
+
+###########################################
+sub test_init {
+###########################################
+ my($level) = @_;
+
+ my $conf = qq{
+ log4perl.logger = $level, testapp
+ log4perl.appender.testapp = Log::Log4perl::Appender::TestBuffer
+ log4perl.appender.testapp.layout= SimpleLayout
+ };
+
+ Log::Log4perl->init( \$conf );
+}
+
+###########################################
+sub debug_logger {
+###########################################
+ my $logger = get_logger("");
+
+ for(1..$nof_tests) {
+ $logger->debug( "message" );
+ }
+}
+
+###########################################
+sub subcat_logger {
+###########################################
+ my $logger = get_logger("a.b.c.d.e.f.g.h.i.j.k");
+
+ for(1..$nof_tests) {
+ $logger->debug( "message" );
+ }
+}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/eg/L4pResurrectable.pm new/Log-Log4perl-1.18/eg/L4pResurrectable.pm
--- old/Log-Log4perl-1.15/eg/L4pResurrectable.pm 2007-06-23 22:22:28.000000000 +0200
+++ new/Log-Log4perl-1.18/eg/L4pResurrectable.pm 2008-08-13 08:16:22.000000000 +0200
@@ -1,7 +1,8 @@
package L4pResurrectable;
use Log::Log4perl qw(:easy);
+use vars qw($VERSION);
-our $VERSION = "0.01";
+$VERSION = "0.01";
sub foo {
###l4p DEBUG "foo was here";
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/lib/Log/Log4perl/Appender/File.pm new/Log-Log4perl-1.18/lib/Log/Log4perl/Appender/File.pm
--- old/Log-Log4perl-1.15/lib/Log/Log4perl/Appender/File.pm 2007-07-17 19:07:10.000000000 +0200
+++ new/Log-Log4perl-1.18/lib/Log/Log4perl/Appender/File.pm 2008-05-16 09:23:42.000000000 +0200
@@ -30,6 +30,7 @@
recreate_check_signal => undef,
recreate_pid_write => undef,
create_at_logtime => 0,
+ header_text => undef,
@options,
};
@@ -119,9 +120,9 @@
if($self->{recreate}) {
$self->{watcher} = Log::Log4perl::Config::Watch->new(
file => $self->{filename},
- ($self->{recreate_check_interval} ?
+ (defined $self->{recreate_check_interval} ?
(check_interval => $self->{recreate_check_interval}) : ()),
- ($self->{recreate_check_signal} ?
+ (defined $self->{recreate_check_signal} ?
(signal => $self->{recreate_check_signal}) : ()),
);
}
@@ -143,6 +144,14 @@
if (defined $self->{utf8}) {
binmode $self->{fh}, ":utf8";
}
+
+ if(defined $self->{header_text}) {
+ if( $self->{header_text} !~ /\n\Z/ ) {
+ $self->{header_text} .= "\n";
+ }
+ my $fh = $self->{fh};
+ print $fh $self->{header_text};
+ }
}
##################################################
@@ -381,7 +390,7 @@
a moved file until the next check occurs, in the worst case
this will happen C seconds after the file
has been moved or deleted. If this is undesirable,
-setting C to 0 will have the appender
+setting C to 0 will have the
appender check the file with I<every> call to C.
=item recreate_check_signal
@@ -418,6 +427,13 @@
the file at log time. Note that this setting lets permission problems
sit undetected until log time, which might be undesirable.
+=item header_text
+
+If you want Log4perl to print a header into every newly opened
+(or re-opened) logfile, set C to either a string
+or a subroutine returning a string. If the message doesn't have a newline,
+a newline at the end of the header will be provided.
+
=back
Design and implementation of this module has been greatly inspired by
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/lib/Log/Log4perl/Appender/Limit.pm new/Log-Log4perl-1.18/lib/Log/Log4perl/Appender/Limit.pm
--- old/Log-Log4perl-1.15/lib/Log/Log4perl/Appender/Limit.pm 2005-01-09 04:36:41.000000000 +0100
+++ new/Log-Log4perl-1.18/lib/Log/Log4perl/Appender/Limit.pm 2008-07-20 03:50:30.000000000 +0200
@@ -15,7 +15,7 @@
our @ISA = qw(Log::Log4perl::Appender);
-our $CVSVERSION = '$Revision: 1.6 $';
+our $CVSVERSION = '$Revision: 1.7 $';
our ($VERSION) = ($CVSVERSION =~ /(\d+\.\d+)/);
###########################################
@@ -259,7 +259,8 @@
If the appender attached to C<Limit> uses C<PatternLayout> with a timestamp
specifier, you will notice that the message timestamps are reflecting the
original log event, not the time of the message rendering in the
-attached appender. Major trickery has applied to accomplish this (Cough!).
+attached appender. Major trickery has been applied to accomplish
+this (Cough!).
=head1 DEVELOPMENT NOTES
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/lib/Log/Log4perl/Appender/Socket.pm new/Log-Log4perl-1.18/lib/Log/Log4perl/Appender/Socket.pm
--- old/Log-Log4perl-1.15/lib/Log/Log4perl/Appender/Socket.pm 2008-01-29 07:06:16.000000000 +0100
+++ new/Log-Log4perl-1.18/lib/Log/Log4perl/Appender/Socket.pm 2008-08-24 05:21:29.000000000 +0200
@@ -16,6 +16,7 @@
my $self = {
name => "unknown name",
silent_recovery => 0,
+ no_warning => 0,
PeerAddr => "localhost",
Proto => 'tcp',
Timeout => 5,
@@ -27,7 +28,9 @@
unless ($self->{defer_connection}){
unless($self->connect(@options)) {
if($self->{silent_recovery}) {
- warn "Connect to $self->{PeerAddr}:$self->{PeerPort} failed: $!";
+ if( ! $self->{no_warning}) {
+ warn "Connect to $self->{PeerAddr}:$self->{PeerPort} failed: $!";
+ }
return $self;
}
die "Connect to $self->{PeerAddr}:$self->{PeerPort} failed: $!";
@@ -137,6 +140,8 @@
can't be established at initialization time, a single warning is issued.
Every log attempt will then try to establish the connection and
discard the message silently if it fails.
+If you don't even want the warning, set the C option to
+a true value.
Connecting at initialization time may not be the best option when
running under Apache1 Apache2/prefork, because the parent process creates
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/lib/Log/Log4perl/Appender/TestArrayBuffer.pm new/Log-Log4perl-1.18/lib/Log/Log4perl/Appender/TestArrayBuffer.pm
--- old/Log-Log4perl-1.15/lib/Log/Log4perl/Appender/TestArrayBuffer.pm 2003-05-31 20:19:42.000000000 +0200
+++ new/Log-Log4perl-1.18/lib/Log/Log4perl/Appender/TestArrayBuffer.pm 2008-08-13 03:03:55.000000000 +0200
@@ -35,14 +35,13 @@
my $appender = Log::Log4perl::Appender::TestArrayBuffer->new(
name => 'buffer',
- min_level => 'debug',
- );
+ );
# Append to the buffer
$appender->log_message(
level = > 'alert',
message => ['first', 'second', 'third'],
- );
+ );
# Retrieve the result
my $result = $appender->buffer();
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/lib/Log/Log4perl/Appender/TestBuffer.pm new/Log-Log4perl-1.18/lib/Log/Log4perl/Appender/TestBuffer.pm
--- old/Log-Log4perl-1.15/lib/Log/Log4perl/Appender/TestBuffer.pm 2006-02-04 21:29:08.000000000 +0100
+++ new/Log-Log4perl-1.18/lib/Log/Log4perl/Appender/TestBuffer.pm 2008-08-13 03:03:40.000000000 +0200
@@ -107,14 +107,13 @@
my $appender = Log::Log4perl::Appender::TestBuffer->new(
name => 'buffer',
- min_level => 'debug',
- );
+ );
# Append to the buffer
$appender->log_message(
level = > 'alert',
message => "I'm searching the city for sci-fi wasabi\n"
- );
+ );
# Retrieve the result
my $result = $appender->buffer();
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/lib/Log/Log4perl/Appender.pm new/Log-Log4perl-1.18/lib/Log/Log4perl/Appender.pm
--- old/Log-Log4perl-1.15/lib/Log/Log4perl/Appender.pm 2006-08-09 06:54:54.000000000 +0200
+++ new/Log-Log4perl-1.18/lib/Log/Log4perl/Appender.pm 2008-05-13 06:39:42.000000000 +0200
@@ -432,7 +432,7 @@
$logger->debug($ip, $user, "signed in");
-causes an off-the-shelf CLog::Log4perl::Screen
+causes an off-the-shelf CLog::Log4perl::Appender::Screen
appender to fire, the appender will
just concatenate the three message chunks passed to it
in order to form a single string.
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/lib/Log/Log4perl/Config.pm new/Log-Log4perl-1.18/lib/Log/Log4perl/Config.pm
--- old/Log-Log4perl-1.15/lib/Log/Log4perl/Config.pm 2007-11-10 01:39:11.000000000 +0100
+++ new/Log-Log4perl-1.18/lib/Log/Log4perl/Config.pm 2008-08-19 23:25:47.000000000 +0200
@@ -20,20 +20,9 @@
our $CONFIG_INTEGRITY_CHECK = 1;
our $CONFIG_INTEGRITY_ERROR = undef;
-# How to map lib4j levels to Log::Dispatch levels
-my @LEVEL_MAP_A = qw(
- DEBUG debug
- INFO info
- INFO notice
- WARN warning
- ERROR error
- FATAL critical
- FATAL alert
- FATAL emergency
-);
-
our $WATCHER;
our $DEFAULT_WATCH_DELAY = 60; # seconds
+our $OPTS = {};
our $OLD_CONFIG;
our $LOGGERS_DEFINED;
@@ -48,9 +37,15 @@
}
###########################################
+sub watcher {
+###########################################
+ return $WATCHER;
+}
+
+###########################################
sub init_and_watch {
###########################################
- my ($class, $config, $delay) = @_;
+ my ($class, $config, $delay, $opts) = @_;
# delay can be a signal name - in this case we're gonna
# set up a signal handler.
@@ -90,6 +85,11 @@
);
}
+ if(defined $opts) {
+ die "Parameter $opts needs to be a hash ref" if ref($opts) ne "HASH";
+ $OPTS = $opts;
+ }
+
eval { _init($class, $config); };
if($@) {
@@ -668,6 +668,7 @@
$string =~ s#^org\.apache\.##;
$string =~ s#^log4j\.##;
+ $string =~ s#^l4p\.##;
$string =~ s#^log4perl\.##i;
$string =~ s#\.#::#g;
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/lib/Log/Log4perl/FAQ.pm new/Log-Log4perl-1.18/lib/Log/Log4perl/FAQ.pm
--- old/Log-Log4perl-1.15/lib/Log/Log4perl/FAQ.pm 2008-02-09 21:45:01.000000000 +0100
+++ new/Log-Log4perl-1.18/lib/Log/Log4perl/FAQ.pm 2008-03-12 22:44:04.000000000 +0100
@@ -1746,6 +1746,8 @@
$Log::Log4perl::caller_depth--;
}
+ 1;
+
and a C<tie> command in the main program to tie STDERR to the trapper
module along with regular Log::Log4perl initialization:
@@ -1761,7 +1763,7 @@
layout => "%d %M: %m%n",
});
- tie *STDERR, Trapper;
+ tie *STDERR, "Trapper";
Make sure not to use STDERR as Log::Log4perl's file appender
here (which would be the default in C<:easy> mode), because it would
@@ -2426,6 +2428,67 @@
messages. But now you know, just use the correct module name and
you'll be fine.
+=head2 Log4perl complains that no initialization happened during shutdown!
+
+If you're using Log4perl log commands in DESTROY methods of your objects,
+you might see confusing messages like
+
+ Log4perl: Seems like no initialization happened. Forgot to call init()?
+ Use of uninitialized value in subroutine entry at
+ /home/y/lib/perl5/site_perl/5.6.1/Log/Log4perl.pm line 134 during global
+ destruction. (in cleanup) Undefined subroutine &main:: called at
+ /home/y/lib/perl5/site_perl/5.6.1/Log/Log4perl.pm line 134 during global
+ destruction.
+
+when the program shuts down. What's going on?
+
+This phenomenon happens if you have circular references in your objects,
+which perl can't clean up when an object goes out of scope but waits
+until global destruction instead. At this time, however, Log4perl has
+already shut down, so you can't use it anymore.
+
+For example, here's a simple class which uses a logger in its DESTROY
+method:
+
+ package A;
+ use Log::Log4perl qw(:easy);
+ sub new { bless {}, shift }
+ sub DESTROY { DEBUG "Waaah!"; }
+
+Now, if the main program creates a self-referencing object, like in
+
+ package main;
+ use Log::Log4perl qw(:easy);
+ Log::Log4perl->easy_init($DEBUG);
+
+ my $a = A->new();
+ $a->{selfref} = $a;
+
+then you'll see the error message shown above during global destruction.
+How to tackle this problem?
+
+First, you should clean up your circular references before global
+destruction. They will not only cause objects to be destroyed in an order
+that's hard to predict, but also eat up memory until the program shuts
+down.
+
+So, the program above could easily be fixed by putting
+
+ $a->{selfref} = undef;
+
+at the end or in an END handler. If that's hard to do, use weak references:
+
+ package main;
+ use Scalar::Util qw(weaken);
+ use Log::Log4perl qw(:easy);
+ Log::Log4perl->easy_init($DEBUG);
+
+ my $a = A->new();
+ $a->{selfref} = weaken $a;
+
+This allows perl to clean up the circular reference when the object
+goes out of scope, and doesn't wait until global destruction.
+
=cut
=head1 SEE ALSO
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/lib/Log/Log4perl/Logger.pm new/Log-Log4perl-1.18/lib/Log/Log4perl/Logger.pm
--- old/Log-Log4perl-1.15/lib/Log/Log4perl/Logger.pm 2008-01-29 07:00:40.000000000 +0100
+++ new/Log-Log4perl-1.18/lib/Log/Log4perl/Logger.pm 2008-08-23 02:51:28.000000000 +0200
@@ -70,7 +70,7 @@
exists $APPENDER_BY_NAME{$appendername}->{appender}) {
# Destroy the specific appender
my $appref = $APPENDER_BY_NAME{$appendername}->{appender};
- eval { $appref->DESTROY() };
+ $appref->DESTROY() if $appref->can("DESTROY");
# Destroy L4p::Appender
$APPENDER_BY_NAME{$appendername}->DESTROY();
delete $APPENDER_BY_NAME{$appendername}->{appender};
@@ -297,7 +297,7 @@
foreach my \$a (\@\$appenders) { #note the closure here
my (\$appender_name, \$appender) = \@\$a;
- print(" Sending message '<\$message>' (\$level) " .
+ print(" Sending message '<\$message->[0]>' (\$level) " .
"to \$appender_name\n") if _INTERNAL_DEBUG;
\$appender->log(
@@ -394,7 +394,15 @@
return <file()))[9],
+ "\n";
+ }
+
# more closures here
if($cond) {
if(!defined \$logger) {
@@ -402,7 +410,19 @@
\$level = pop;
}
- Log::Log4perl->init_and_watch();
+ my \$init_permitted = 1;
+
+ if(exists \$Log::Log4perl::Config::OPTS->{ preinit_callback } ) {
+ print "Calling preinit_callback\n" if _INTERNAL_DEBUG;
+ \$init_permitted =
+ \$Log::Log4perl::Config::OPTS->{ preinit_callback }->(
+ Log::Log4perl::Config->watcher()->file() );
+ print "Callback returned \$init_permitted\n" if _INTERNAL_DEBUG;
+ }
+
+ if( \$init_permitted ) {
+ Log::Log4perl->init_and_watch();
+ }
my \$methodname = lc(\$level);
@@ -414,6 +434,10 @@
\$logger->\$methodname(\@_); # send the message
# to the new configuration
return; #and return, we're done with this incarnation
+ } else {
+ if(_INTERNAL_DEBUG) {
+ print "Conditional returned false\n";
+ }
}
EOL
}
@@ -428,7 +452,6 @@
return q{$Log::Log4perl::Config::Watch::SIGNAL_CAUGHT};
}
- # In this mode, we check if the config file has been modified
return q{time() > $Log::Log4perl::Config::Watch::NEXT_CHECK_TIME
and $Log::Log4perl::Config::WATCHER->change_detected()};
@@ -773,10 +796,12 @@
# Added these to have is_xxx functions as fast as xxx functions
# -ms
+
+ my $islevel = "is_" . $level;
+ my $islclevel = "is_" . $lclevel;
*{__PACKAGE__ . "::is_$lclevel"} = sub {
- $_[0]->{"is_" . $level}->($_[0], "is_" . $lclevel) if
- defined $_[0]->{$level};
+ $_[0]->{$islevel}->($_[0], $islclevel);
};
# Add the isXxxEnabled() methods as identical to the is_xxx
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/lib/Log/Log4perl.pm new/Log-Log4perl-1.18/lib/Log/Log4perl.pm
--- old/Log-Log4perl-1.15/lib/Log/Log4perl.pm 2008-02-10 09:04:47.000000000 +0100
+++ new/Log-Log4perl-1.18/lib/Log/Log4perl.pm 2008-08-24 08:02:56.000000000 +0200
@@ -16,7 +16,7 @@
use constant _INTERNAL_DEBUG => 1;
-our $VERSION = '1.15';
+our $VERSION = '1.18';
# set this to '1' if you're using a wrapper
# around Log::Log4perl
@@ -1133,6 +1133,8 @@
=head1 Categories
+B
CLog::Log4perl uses I<categories> to determine if a log statement in
a component should be executed or suppressed at the current logging level.
Most of the time, these categories are just the classes the log statements
@@ -1526,6 +1528,21 @@
either by a signal or if the delay period expired and the change is
detected. This behaviour might change in the future.
+To allow the application to intercept and control a configuration reload
+in init_and_watch mode, a callback can be specified:
+
+ Log::Log4perl->init_and_watch($conf_file, 10, {
+ preinit_callback => \&callback });
+
+If Log4perl determines that the configuration needs to be reloaded, it will
+call the C function without parameters. If the callback
+returns a true value, Log4perl will proceed and reload the configuration. If
+the callback returns a false value, Log4perl will keep the old configuration
+and skip reloading it until the next time around. Inside the callback, an
+application can run all kinds of checks, including accessing the configuration
+file, which is available via
+C.
+
=head2 Variable Substitution
To avoid having to retype the same expressions over and over again,
@@ -2573,13 +2590,13 @@
Contributors (in alphabetical order):
Ateeq Altaf, Cory Bennett, Jeremy Bopp, Hutton Davidson, Chris R.
Donnelly, Matisse Enzer, Hugh Esco, James FitzGibbon, Carl Franks,
- Dennis Gregorovic, Paul Harrington, David Hull, Robert Jacobson,
- Jeff Macdonald, Markus Peter, Brett Rann, Erik Selberg, Aaron
- Straup Cope, Lars Thegler, David Viner, Mac Yang.
+ Dennis Gregorovic, Andy Grundman, Paul Harrington, David Hull,
+ Robert Jacobson, Jeff Macdonald, Markus Peter, Brett Rann, Erik
+ Selberg, Aaron Straup Cope, Lars Thegler, David Viner, Mac Yang.
=head1 COPYRIGHT AND LICENSE
-Copyright 2002-2007 by Mike Schilli E<lt>m@perlmeister.comE<gt> and Kevin Goess
+Copyright 2002-2008 by Mike Schilli E<lt>m@perlmeister.comE<gt> and Kevin Goess
E<lt>cpan@goess.orgE<gt>.
This library is free software; you can redistribute it and/or modify
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/MANIFEST new/Log-Log4perl-1.18/MANIFEST
--- old/Log-Log4perl-1.15/MANIFEST 2008-02-10 09:07:10.000000000 +0100
+++ new/Log-Log4perl-1.18/MANIFEST 2008-08-24 08:06:38.000000000 +0200
@@ -1,5 +1,6 @@
Changes
eg/5005it.pl
+eg/benchmarks/simple
eg/color
eg/jabber.conf
eg/L4pResurrectable.pm
@@ -124,6 +125,7 @@
t/052Utf8.t
t/053Resurrect.t
t/054Subclass.t
+t/055AppDestroy.t
t/compare.pl
t/deeper1.expected
t/deeper6.expected
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/META.yml new/Log-Log4perl-1.18/META.yml
--- old/Log-Log4perl-1.15/META.yml 2008-02-10 09:07:15.000000000 +0100
+++ new/Log-Log4perl-1.18/META.yml 2008-08-24 08:06:41.000000000 +0200
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: Log-Log4perl
-version: 1.15
+version: 1.18
abstract: Log4j implementation for Perl
license: ~
generated_by: ExtUtils::MakeMaker version 6.31
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/README new/Log-Log4perl-1.18/README
--- old/Log-Log4perl-1.15/README 2008-02-10 09:07:10.000000000 +0100
+++ new/Log-Log4perl-1.18/README 2008-08-24 08:06:38.000000000 +0200
@@ -1,5 +1,5 @@
######################################################################
- Log::Log4perl 1.15
+ Log::Log4perl 1.18
######################################################################
NAME
@@ -620,10 +620,12 @@
be replaced by the return value of the filter function.
Categories
- "Log::Log4perl" uses *categories* to determine if a log statement in a
- component should be executed or suppressed at the current logging level.
- Most of the time, these categories are just the classes the log
- statements are located in:
+ Categories are also called "Loggers" in Log4perl, both refer to the the
+ same thing and these terms are used interchangeably. "Log::Log4perl"
+ uses *categories* to determine if a log statement in a component should
+ be executed or suppressed at the current logging level. Most of the
+ time, these categories are just the classes the log statements are
+ located in:
package Candy::Twix;
@@ -985,6 +987,21 @@
a signal or if the delay period expired and the change is detected. This
behaviour might change in the future.
+ To allow the application to intercept and control a configuration reload
+ in init_and_watch mode, a callback can be specified:
+
+ Log::Log4perl->init_and_watch($conf_file, 10, {
+ preinit_callback => \&callback });
+
+ If Log4perl determines that the configuration needs to be reloaded, it
+ will call the "preinit_callback" function without parameters. If the
+ callback returns a true value, Log4perl will proceed and reload the
+ configuration. If the callback returns a false value, Log4perl will keep
+ the old configuration and skip reloading it until the next time around.
+ Inside the callback, an application can run all kinds of checks,
+ including accessing the configuration file, which is available via
+ "Log::Log4perl::Config->watcher()->file()".
+
Variable Substitution
To avoid having to retype the same expressions over and over again,
Log::Log4perl's configuration files support simple variable
@@ -1950,12 +1967,12 @@
Contributors (in alphabetical order):
Ateeq Altaf, Cory Bennett, Jeremy Bopp, Hutton Davidson, Chris R.
Donnelly, Matisse Enzer, Hugh Esco, James FitzGibbon, Carl Franks,
- Dennis Gregorovic, Paul Harrington, David Hull, Robert Jacobson,
- Jeff Macdonald, Markus Peter, Brett Rann, Erik Selberg, Aaron
- Straup Cope, Lars Thegler, David Viner, Mac Yang.
+ Dennis Gregorovic, Andy Grundman, Paul Harrington, David Hull,
+ Robert Jacobson, Jeff Macdonald, Markus Peter, Brett Rann, Erik
+ Selberg, Aaron Straup Cope, Lars Thegler, David Viner, Mac Yang.
COPYRIGHT AND LICENSE
- Copyright 2002-2007 by Mike Schilli and Kevin Goess
+ Copyright 2002-2008 by Mike Schilli and Kevin Goess
.
This library is free software; you can redistribute it and/or modify it
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/t/017Watch.t new/Log-Log4perl-1.18/t/017Watch.t
--- old/Log-Log4perl-1.15/t/017Watch.t 2007-02-08 07:53:47.000000000 +0100
+++ new/Log-Log4perl-1.18/t/017Watch.t 2008-06-22 06:47:30.000000000 +0200
@@ -8,6 +8,11 @@
use Log::Log4perl;
use File::Spec;
+sub trunc {
+ open FILE, ">$_[0]" or die "Cannot open $_[0]";
+ close FILE;
+}
+
BEGIN {
if ($] < 5.006) {
plan skip_all => "Only with perl >= 5.006";
@@ -157,51 +162,49 @@
is($log, "INFO - info message\nDEBUG animal.dog - 2nd debug message\nINFO animal.dog - 2nd info message\nINFO animal.dog - 2nd info message again\nINFO - 3rd info message\n", "after reload");
-
-# ***************************************************************
-# Check the 'recreate' feature
-
-trunc($testfile);
-my $conf3 = <init(\$conf3);
-
-$logger = Log::Log4perl::get_logger('animal.dog');
-$logger->info("test1");
-open (LOG, $testfile) or die "can't open $testfile $!";
-is(scalar <LOG>, "INFO - test1\n", "Before recreate");
-close LOG;
-
-trunc($testfile);
-$logger->info("test2");
-open (LOG, $testfile) or die "can't open $testfile $!";
-is(scalar <LOG>, "INFO - test2\n", "After recreate");
-close LOG;
-
-trunc($testfile);
-trunc($testconf);
-
-sub trunc {
- open FILE, ">$_[0]" or die "Cannot open $_[0]";
- close FILE;
-}
+
+ Log::Log4perl->init(\$conf4);
+
+ $logger = Log::Log4perl::get_logger('animal.dog');
+ $logger->info("test1");
+ open (LOG, $testfile) or die "can't open $testfile $!";
+ is(scalar <LOG>, "INFO - test1\n", "Before recreate");
+ close LOG;
+
+ unlink $testfile or die "Cannot unlink $testfile: $!";
+ $logger->info("test2");
+ open (LOG, $testfile) or die "can't open $testfile $!";
+ is(scalar <LOG>, "INFO - test2\n", "After recreate");
+ close LOG;
+
+ trunc($testfile);
+ trunc($testconf);
+};
# ***************************************************************
# Check the 'recreate' feature with signal handling
+
SKIP: {
- skip "Signal handling not supported on Win32", 5 if $^O eq "MSWin32";
+ skip "File recreation not supported on Win32", 5 if $^O eq "MSWin32";
- my $conf3 = <init(\$conf3);
+ Log::Log4perl->init(\$conf5);
$logger = Log::Log4perl::get_logger('animal.dog');
$logger->info("test1");
@@ -232,7 +235,7 @@
# Check the 'recreate' feature with check_interval
trunc($testfile);
-$conf3 = <logdie("Log and die!"); };
my $app0 = Log::Log4perl::Appender::TestBuffer->by_name("A1");
# print "Buffer: ", $app0->buffer(), "\n";
-like($app0->buffer(), qr/024WarnDieCarp.t-145: Log and die!/,
+like($app0->buffer(), qr/024WarnDieCarp.t-$line_number: Log and die!/,
"%F-%L adjustment");
######################################################################
@@ -157,26 +159,31 @@
$app0->buffer("");
package Weirdo;
+our $foo_line;
+our $bar_line;
+
use Log::Log4perl qw(get_logger);
sub foo {
my $logger = get_logger("Twix::Bar");
+ $foo_line = __LINE__ + 1;
$logger->logcroak("Inferno!");
}
sub bar {
my $logger = get_logger("Twix::Bar");
+ $bar_line = __LINE__ + 1;
$logger->logdie("Inferno!");
}
package main;
eval { Weirdo::foo(); };
-like($app0->buffer(), qr/171/,
+like($app0->buffer(), qr/$Weirdo::foo_line/,
"Check logcroak/Carp");
$app0->buffer("");
eval { Weirdo::bar(); };
-like($app0->buffer(), qr/167/,
+like($app0->buffer(), qr/$Weirdo::bar_line/,
"Check logdie");
######################################################################
@@ -186,9 +193,11 @@
$app0->buffer("");
package Foo;
+our $foo_line;
use Log::Log4perl qw(get_logger);
sub foo {
my $logger = get_logger("Twix::Bar");
+ $foo_line = __LINE__ + 1;
$logger->logcarp("Inferno!");
}
@@ -204,7 +213,7 @@
use Carp;
skip "Detected buggy Carp.pm (upgrade to perl-5.8.*)", 1 unless
defined $Carp::VERSION;
- like($app0->buffer(), qr/197/,
+ like($app0->buffer(), qr/$Foo::foo_line/,
"Check logcarp");
}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/t/026FileApp.t new/Log-Log4perl-1.18/t/026FileApp.t
--- old/Log-Log4perl-1.15/t/026FileApp.t 2007-11-19 01:24:57.000000000 +0100
+++ new/Log-Log4perl-1.18/t/026FileApp.t 2008-06-21 23:48:16.000000000 +0200
@@ -27,14 +27,22 @@
my $testfile = File::Spec->catfile($WORK_DIR, "test26.log");
-BEGIN {plan tests => 15}
+BEGIN {plan tests => 16}
-END { unlink $testfile;
- unlink "${testfile}_1";
- unlink "${testfile}_2";
- unlink "${testfile}_3";
+END {
+ unlink_testfiles();
}
+sub unlink_testfiles {
+ unlink $testfile;
+ unlink "${testfile}_1";
+ unlink "${testfile}_2";
+ unlink "${testfile}_3";
+ unlink "${testfile}_4";
+}
+
+unlink_testfiles();
+
####################################################
# First, preset the log file with some content
####################################################
@@ -255,6 +263,8 @@
#########################################################
# Testing create_at_logtime
#########################################################
+unlink "${testfile}_3"; # delete leftovers from previous tests
+
$data = qq(
log4perl.category = DEBUG, Logfile
log4perl.appender.Logfile = Log::Log4perl::Appender::File
@@ -274,3 +284,24 @@
close FILE;
ok($content, "INFO - File1\n");
+
+unlink "${testfile}_3";
+
+#########################################################
+# Print a header into a newly opened file
+#########################################################
+$data = qq(
+log4perl.category = DEBUG, Logfile
+log4perl.appender.Logfile = Log::Log4perl::Appender::File
+log4perl.appender.Logfile.filename = ${testfile}_4
+log4perl.appender.Logfile.header_text = This is a nice header.
+log4perl.appender.Logfile.layout = Log::Log4perl::Layout::SimpleLayout
+);
+
+Log::Log4perl->init(\$data);
+open FILE, "<${testfile}_4" or die "Cannot open ${testfile}_4";
+$content = join '', <FILE>;
+close FILE;
+
+ok($content, "This is a nice header.\n", "header_text");
+
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/t/027Watch2.t new/Log-Log4perl-1.18/t/027Watch2.t
--- old/Log-Log4perl-1.15/t/027Watch2.t 2006-10-27 04:31:37.000000000 +0200
+++ new/Log-Log4perl-1.18/t/027Watch2.t 2008-08-23 02:51:43.000000000 +0200
@@ -15,7 +15,7 @@
if ($] < 5.006) {
plan skip_all => "Only with perl >= 5.006";
} else {
- plan tests => 19;
+ plan tests => 20;
}
}
@@ -131,49 +131,75 @@
# filename/linenumber were referring to 'eval', not the actual file
# name/line number of the message.
+my $counter = 0;
+my $reload_permitted = 1;
conf_file_write();
-Log::Log4perl->init_and_watch($testconf, 1);
+Log::Log4perl->init_and_watch($testconf, 1, {
+ preinit_callback => sub {
+ $counter++;
+#print "Counter incremented to $counter\n";
+ return $reload_permitted;
+ },
+});
+my $line_ref = __LINE__ + 1;
DEBUG("first");
my $buf = Log::Log4perl::Appender::TestBuffer->by_name("Testbuffer");
- like($buf->buffer(), qr/027Watch2.t 138> first/,
- "init-and-watch caller level");
+ like($buf->buffer(), qr/027Watch2.t $line_ref> first/,
+ "init-and-watch caller level first");
$buf->buffer("");
-conf_file_write();
+print "Sleeping 1 second\n";
sleep(1);
+conf_file_write();
+$line_ref = __LINE__ + 1;
DEBUG("second");
$buf = Log::Log4perl::Appender::TestBuffer->by_name("Testbuffer");
- like($buf->buffer(), qr/027Watch2.t 146> second/,
- "init-and-watch caller level");
+ like($buf->buffer(), qr/027Watch2.t $line_ref> second/,
+ "init-and-watch caller level second");
$buf->buffer("");
-conf_file_write();
-sleep(1);
+$reload_permitted = 0;
+print "Sleeping 2 seconds\n";
+sleep(2);
+conf_file_write("FATAL");
+$line_ref = __LINE__ + 1;
DEBUG("third");
$buf = Log::Log4perl::Appender::TestBuffer->by_name("Testbuffer");
- like($buf->buffer(), qr/027Watch2.t 154> third/,
- "init-and-watch caller level");
+ like($buf->buffer(), qr/027Watch2.t $line_ref> third/,
+ "init-and-watch caller level third");
$buf->buffer("");
-DEBUG("fourth");
+$reload_permitted = 1;
+print "Sleeping 2 seconds\n";
+sleep(2);
+conf_file_write("ERROR");
+$line_ref = __LINE__ + 1;
+ERROR("third");
$buf = Log::Log4perl::Appender::TestBuffer->by_name("Testbuffer");
- like($buf->buffer(), qr/027Watch2.t 160> fourth/,
- "init-and-watch caller level");
+ like($buf->buffer(), qr/027Watch2.t $line_ref> third/,
+ "init-and-watch caller level third");
$buf->buffer("");
+ok($counter >= 1, "Callback counter check");
+
###########################################
sub conf_file_write {
###########################################
+ my($level) = @_;
+
+ $level = "DEBUG" unless defined $level;
+
open FILE, ">$testconf" or die $!;
print FILE < %m %n
EOT
close FILE;
+#print "Config written\n";
}
unlink $testconf;
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Log-Log4perl-1.15/t/055AppDestroy.t new/Log-Log4perl-1.18/t/055AppDestroy.t
--- old/Log-Log4perl-1.15/t/055AppDestroy.t 1970-01-01 01:00:00.000000000 +0100
+++ new/Log-Log4perl-1.18/t/055AppDestroy.t 2008-04-25 01:36:03.000000000 +0200
@@ -0,0 +1,45 @@
+#!/usr/bin/perl
+###################################################################
+# Check if a custom appender with a destroy handler gets its
+# warning through
+###################################################################
+package SomeAppender;
+our @ISA = qw(Log::Log4perl::Appender);
+sub new {
+ bless {}, shift;
+}
+sub log {}
+sub DESTROY {
+ warn "Horrible Warning!";
+}
+
+package main;
+use warnings;
+use strict;
+use Test::More;
+use Log::Log4perl qw(:easy);
+
+my $warnings;
+
+$SIG{__WARN__} = sub {
+ $warnings .= $_[0];
+};
+
+my $conf = q(
+log4perl.category = DEBUG, SomeA
+log4perl.appender.SomeA = SomeAppender
+log4perl.appender.SomeA.layout = Log::Log4perl::Layout::SimpleLayout
+);
+
+Log::Log4perl->init(\$conf);
+
+plan tests => 1;
+
+my $logger = get_logger();
+$logger->debug("foo");
+
+Log::Log4perl::Logger->cleanup();
+
+END {
+ like $warnings, qr/Horrible Warning!/, "app destruction warning caught";
+}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org