J. Shirley wrote:
On Sat, Apr 19, 2008 at 8:01 AM, David Wright <[EMAIL PROTECTED]> wrote:
Hi,

 It seems that 'autoflush' doesn't mean what it usually does in
Catalyst::Log::Log4perl. It usually means that a write should happen
immediately, and not be buffered.

 That isn't the behaviour in Catalyst::Log::Log4perl, either when set using
the log4perl conf, or when using the option to new(). The option to new()
disables 'abort', which I think is a misunderstanding. The logging functions
always simply push to the log4perlstack, which is only flushed after the
request has been mostly handled.

 In order to get autoflush working as expected, I have had to create a
 derived class and override _log():

 sub _log {
 my $self = shift;
 $self->SUPER::_log(@_);
 $self->_flush if scalar(caller(1)) =~ /^MyApp(::|$)/;
 }

 perl -v: v5.8.8 built for i486-linux-gnu-thread-multi
 uname -a: Linux PC-5023452 2.6.22-14-generic #1 SMP Fri Feb 1 04:59:50
 UTC 2008 i686 GNU/Linux
 Catalyst::Log::Log4perl version: 1.0

 I've raised a bug in RT for this:
http://rt.cpan.org/Public/Bug/Display.html?id=35221

 Thanks,
 David Wright



David,

Could you throw a test case in with this (either on the RT bug or in
this mail) and I'll get a patch put in place?

Diff to 10-basic.t attached.

Cheers,
David




6c6
< use Test::More tests => 14;
---
> use Test::More tests => 15;
91a92,106
> 
> 
> # check that if autoflush is enabled, the log is written to immediately
> $app->log(
>     Catalyst::Log::Log4perl->new( \<<CONF, override_cspecs => 1, autoflush => 1 ) );
> log4perl.rootLogger=WARN, LOG
> log4perl.appender.LOG=Log::Log4perl::Appender::String
> log4perl.appender.LOG.layout=PatternLayout
> log4perl.appender.LOG.layout.ConversionPattern=[%c] %m
> CONF
> 
> $appender->layout( Log::Log4perl::Layout::PatternLayout->new('%m') );
> $c = $app->log->warn('delay');
> log_like( qr|delay|, "autoflush" );
> 
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to