[Catalyst-dev] Log not being setup properly

Jason Kohles email at jasonkohles.com
Wed Sep 27 20:45:23 CEST 2006


On Sep 27, 2006, at 1:41 PM, Adam Jacob wrote:

> On Sep 27, 2006, at 5:53 AM, Matt S Trout wrote:
>> Yeah, I'm assuming that's mostly just a shortcut for default log
>> levels in the
>> absence of config.
>>
>> Actually ... shouldn't -Log determine the type of logger? i.e. -
>> Log=Log4Perl
>> just like -Engine= and -Dispatcher= work?
>
> That sounds like a pretty fine idea to me.  I've never been
> particularly fond of
>
> __PACKAGE__->log(Catalyst::Log::Log4perl->new);
>
> That looks like a pretty simple patch to Catalyst.pm's setup_log.
> The current behavior takes -Debug and set's what -Log would normally
> have:
>
> __PACKAGE->setup(qw/-Debug/);
>
> So assuming nobody is actually using:
>
> __PACKAGE__->setup(qw/-Log=Error/);
>
I'd be surprised if anyone is actually using it, as it doesn't work.   
In fact the code doesn't even seem to attempt to make it work,  
although there are other areas where it suggests that was the intent.


> If would be easy enough to override.  We could do some magic as well:
>
> __PACKAGE__->setup(qw/-Log=Log4perl);
>
> Basically just reserving the Catalyst::Log levels as special words,
> never allowed to be Catalyst::Log descendants.
>
> I'll be happy to work up a patch, but I've got a fairly full load of
> commitments for the next couple of weeks.  Want I should stick this
> on the todo list?
>
As it happens, I had worked up a patch for this recently, while  
trying to track down why ->setup(qw/-Log=info/) didn't actually  
work.  It probably needs some cleanup (and tests), but the attached  
patch "works-for-me".  It allows you to do setup like this:

__PACKAGE__->setup(qw/-Log=Log4perl/);

or

__PACKAGE__->setup(qw/-Log=info,debug/);

and, if you were really getting into it and wanted to actually make a  
log class with the same name as a log level, you could even get away  
with that like this:

__PACKAGE__->setup(qw/-Log=Catalyst::Log::Debug/);

I was planning to clean this up and add some tests before sending it  
to the list, but since it came up...  If I get some time in the next  
few days, I'll do it up right...

-- 
Jason Kohles
email at jasonkohles.com
http://www.jasonkohles.com/
"A witty saying proves nothing."  -- Voltaire

-------------- next part --------------
A non-text attachment was scrubbed...
Name: catalyst-log-class.diff
Type: application/octet-stream
Size: 3237 bytes
Desc: not available
Url : http://lists.rawmode.org/pipermail/catalyst-dev/attachments/20060927/12732638/attachment-0001.obj 
-------------- next part --------------



More information about the Catalyst-dev mailing list