From: Jim C. <jc...@di...> - 2003-06-19 17:46:51
Attachments:
patch
|
Mike, etal, I just tested Log4perl against perl 5.8.x MAINT19732 attached (and included below) is a patch to fix 1 a syntax error in Level, 2 a NOT-READY one against t/032RollingFile.t 1st corrects syntax which is a variant of my $foo = 1 if $bar; # which is deprecated I commented out 'use vars', presumably youll delete it. 2. the test file has a my $WORK_DIR redefined, but with that fixed still fails for me on rotation tests. $> more t/tmp/rolltest.log INFO cat1 - info message 1 WARN cat1 - warning message 1 FATAL cat1 - fatal message 1 I presume there to be some incompleteness in the Log::Dispatch replacement. I dug a bit, but dont have time to finish the job. hth, jimc diff -ur Log-Log4perl-0.34/lib/Log/Log4perl/Level.pm Log-Log4perl-0.34-patched/lib/Log/Log4perl/Level.pm --- Log-Log4perl-0.34/lib/Log/Log4perl/Level.pm Sat May 31 11:23:21 2003 +++ Log-Log4perl-0.34-patched/lib/Log/Log4perl/Level.pm Thu Jun 19 06:53:06 2003 @@ -19,12 +19,13 @@ use constant OFF_INT => (2 ** 31) - 1; no strict qw(refs); -use vars qw(%PRIORITY %LEVELS); +#use vars qw(%PRIORITY %LEVELS); +our (%PRIORITY, %LEVELS, %SYSLOG, %L4P_TO_LD); -our %PRIORITY = (); # unless (%PRIORITY); -our %LEVELS = () unless (%LEVELS); -our %SYSLOG = () unless (%SYSLOG); -our %L4P_TO_LD = () unless (%L4P_TO_LD); +%PRIORITY = (); # unless (%PRIORITY); +%LEVELS = () unless (%LEVELS); +%SYSLOG = () unless (%SYSLOG); +%L4P_TO_LD = () unless (%L4P_TO_LD); sub add_priority { my ($prio, $intval, $syslog, $log_dispatch_level) = @_; Only in Log-Log4perl-0.34-patched/lib/Log/Log4perl: Level.pm~ Only in Log-Log4perl-0.34-patched/: pm_to_blib diff -ur Log-Log4perl-0.34/t/032JRollFile.t Log-Log4perl-0.34-patched/t/032JRollFile.t --- Log-Log4perl-0.34/t/032JRollFile.t Sat May 31 11:38:55 2003 +++ Log-Log4perl-0.34-patched/t/032JRollFile.t Thu Jun 19 06:56:46 2003 @@ -21,7 +21,7 @@ mkdir("$WORK_DIR", 0755) || die "can't create $WORK_DIR ($!)"; } -my $WORK_DIR = File::Spec->catfile(qw(t tmp)); +$WORK_DIR = File::Spec->catfile(qw(t tmp)); use vars qw(@outfiles); @outfiles = (File::Spec->catfile($WORK_DIR, 'rolltest.log'), File::Spec->catfile($WORK_DIR, 'rolltest.log.1'), File::Spec->catfile($WORK_DIR, 'rolltest.log.2'),); @@ -64,6 +64,6 @@ ok(! -e File::Spec->catfile($WORK_DIR, 'rolltest.log.3')); foreach my $f (@outfiles){ - unlink $f if (-e $f); + #unlink $f if (-e $f); } |
From: Mike S. <m...@pe...> - 2003-06-20 08:02:19
|
On Thu, 19 Jun 2003, Jim Cromie wrote: > attached (and included below) is a patch to fix > 1 a syntax error in Level, > 2 a NOT-READY one against t/032RollingFile.t Thanks, I've applied your first patch. The 'my' fix for the 032 test case was already checked into CVS. The real problem with Log::Dispatch::FileRotate is pretty severe, though: Looks like the latest Log::Dispatch::FileRotate (1.09) expects its 'size' parameter now in megabytes, not bytes. I've changed both JavaMap/RollingFileAppender.pm and the test case, here's the diff between the last release and now: Index: lib/Log/Log4perl/JavaMap/RollingFileAppender.pm =================================================================== RCS file: /cvsroot/log4perl/Log-Log4perl/lib/Log/Log4perl/JavaMap/RollingFileAppender.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -a -u -r1.2 -r1.3 --- lib/Log/Log4perl/JavaMap/RollingFileAppender.pm 18 Nov 2002 20:04:28 -0000 1.2 +++ lib/Log/Log4perl/JavaMap/RollingFileAppender.pm 20 Jun 2003 07:46:35 -0000 1.3 @@ -57,10 +57,9 @@ }elsif (defined $data->{size}{value}){ $size = $data->{size}{value}; }else{ - $size = 10_000_000; + $size = 10; } - return Log::Log4perl::Appender->new("Log::Dispatch::FileRotate", name => $appender_name, filename => $filename, @@ -90,7 +89,7 @@ File Append "true|false|1|0" default=true BufferedIO "true|false|1|0" default=false (i.e. autoflush is on) - MaxFileSize default 10_000_000 + MaxFileSize default=10 (in MB) MaxBackupIndex default is 1 Possible config properties for Log::Dispatch::FileRotate are Index: t/032JRollFile.t =================================================================== RCS file: /cvsroot/log4perl/Log-Log4perl/t/032JRollFile.t,v retrieving revision 1.3 retrieving revision 1.6 diff -a -u -r1.3 -r1.6 --- t/032JRollFile.t 31 May 2003 18:51:29 -0000 1.3 +++ t/032JRollFile.t 20 Jun 2003 07:36:29 -0000 1.6 @@ -21,7 +21,6 @@ mkdir("$WORK_DIR", 0755) || die "can't create $WORK_DIR ($!)"; } -my $WORK_DIR = File::Spec->catfile(qw(t tmp)); use vars qw(@outfiles); @outfiles = (File::Spec->catfile($WORK_DIR, 'rolltest.log'), File::Spec->catfile($WORK_DIR, 'rolltest.log.1'), File::Spec->catfile($WORK_DIR, 'rolltest.log.2'),); @@ -30,14 +29,13 @@ unlink $f if (-e $f); } - my $conf = <<CONF; log4j.category.cat1 = INFO, myAppender log4j.appender.myAppender=org.apache.log4j.RollingFileAppender log4j.appender.myAppender.File=@{[File::Spec->catfile($WORK_DIR, 'rolltest.log')]} #this will roll the file after one write -log4j.appender.myAppender.MaxFileSize=15 +log4j.appender.myAppender.MaxFileSize=@{[1/1024]} log4j.appender.myAppender.MaxBackupIndex=2 log4j.appender.myAppender.layout=org.apache.log4j.PatternLayout log4j.appender.myAppender.layout.ConversionPattern=%-5p %c - %m%n @@ -48,17 +46,17 @@ my $logger = Log::Log4perl->get_logger('cat1'); -$logger->debug("debugging message 1 "); -$logger->info("info message 1 "); -$logger->warn("warning message 1 "); -$logger->fatal("fatal message 1 "); - +$logger->debug("x" x 1024 . "debugging message 1 "); +$logger->info("x" x 1024 . "info message 1 "); +$logger->warn("x" x 1024 . "warning message 1 "); +$logger->fatal("x" x 1024 . "fatal message 1 "); +my $rollfile = File::Spec->catfile($WORK_DIR, 'rolltest.log.2'); -open (F, File::Spec->catfile($WORK_DIR, 'rolltest.log.2')); +open F, $rollfile or die "Cannot open $rollfile"; my $result = <F>; close F; -like($result, qr/^INFO cat1 - info message 1/); +like($result, qr/^INFO cat1 - x+info message 1/); #MaxBackupIndex is 2, so this file shouldn't exist ok(! -e File::Spec->catfile($WORK_DIR, 'rolltest.log.3')); @@ -66,4 +64,3 @@ foreach my $f (@outfiles){ unlink $f if (-e $f); } - -- Mike Mike Schilli m...@pe... http://perlmeister.com |
From: Kevin G. <ke...@go...> - 2003-06-20 15:30:46
|
> The real problem with Log::Dispatch::FileRotate is pretty severe, though: > Looks like the latest Log::Dispatch::FileRotate (1.09) expects its 'size' > parameter now in megabytes, not bytes. Mike, Since the point of JavaMap::RollingFileAppender is to be API-compatible with the log4j module, it should continue to accept the parameter in bytes and translate to megabytes when it calls the Log::Dispatch module. And don't forget to change the required version number of FileRotate if we're requiring the latest version. -- Happy Trails . . . Kevin M. Goess (and Anne and Frank) 904 Carmel Ave. Albany, CA 94706 (510) 525-5217 |
From: Mike S. <log...@pe...> - 2003-06-22 03:26:43
|
On Fri, 20 Jun 2003, Kevin Goess wrote: > Since the point of JavaMap::RollingFileAppender is to be API-compatible > with the log4j module, it should continue to accept the parameter in > bytes and translate to megabytes when it calls the Log::Dispatch module. Good catch, thanks, I've checked in the fix. BTW, if we wanted to be fully compatible, we'd have to add support for the following, too (out of log4j): In configuration files, the <b>MaxFileSize</b> option takes an long integer in the range 0 - 2^63. You can specify the value with the suffixes "KB", "MB" or "GB" so that the integer is interpreted being expressed respectively in kilobytes, megabytes or gigabytes. For example, the value "10KB" will be interpreted as 10240. > And don't forget to change the required version number of FileRotate if > we're requiring the latest version. Another good catch, 1.09 is now required both in JavaMap/RollingFileAppender and in the test case. Pushed 0.35 to the web site for beta testing ... -- Mike Mike Schilli log...@pe... http://perlmeister.com http://log4perl.sourceforge.net |