[Catalyst] config log in component?
Tomas Doran
bobtfish at bobtfish.net
Mon Mar 23 19:10:26 GMT 2009
Dylan Martin wrote:
> Hello everyone.
>
> I'm using Catalyst for the first time and I'm using Authen::Simple for
> authentication. Authen::Simple and Catalyst have very similar ideas
> about logging, where your Authen::Simple object and your Cat object
> each take a Log4Perl/Log::Dispatch object like so:
>
<snip>
> Is there a way in the config file (Config::Any in my case) to tell the
> Authen::Simple code to use the logger from Cat? EG
>
>
Not currently, but looks like a really really trivial patch to me:
--- Simple.pm 2008-08-03 17:39:49.000000000 +0100
+++ Simple.pm.t0m 2009-03-23 19:06:58.000000000 +0000
@@ -25,8 +25,12 @@
foreach my $auth (@{ $config->{'authen'} }){
my $class = "Authen::Simple::$auth->{'class'}";
$app->log->debug("Loading class: $class");
+ my %extra_args;
+ if ($auth->{use_catalyst_logger}) {
+ $extra_args{log} = $app->log;
+ }
load $class;
- push @auth_arr, $class->new(%{ $auth->{'args'} });
+ push @auth_arr, $class->new(%{ $auth->{'args'} }, %extra_args);
}
$self->{'_config'}->{'password_field'} ||= 'password';
Try that? (Untested)
> <IMAP>
> <credential>
> class Authen::Simple
> <authen>
> class IMAP
> <args>
> host imap.sccd.ctc.edu
> protocol IMAPS
> </args>
>
use_catalyst_logger 1
> </authen>
> </credential>
> # no store
> </IMAP>
>
Should then do what you want.
Have a play, and assuming it works, document it and submit a proper
patch (with docs) to the author?
Cheers
t0m
More information about the Catalyst
mailing list