[Catalyst] Catalyst::Log::Log4perl autoflush

Matt S Trout dbix-class at trout.me.uk
Sun Apr 20 15:17:11 BST 2008


On Sun, Apr 20, 2008 at 01:56:04AM +0100, David Wright wrote:
> >> 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
> >>
> >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?
> 
> Hello Jay,
> 
> Which of the autoflushes should I test against: the parameter to 
> new(), or the option in a log4perl configuration file?
> 
> Do you (or others) agree that the autoflush option to new() is a misnomer? 
> If not, wouldn't my test simply prove that the code doesn't do what it 
> doesn't say it does?

The autoflush option to new has the right name, but does the wrong thing.

So your test should prove that the code doesn't do what it's supposed to
even though it accepts the parameter.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the Catalyst mailing list