Personally, I'd add a few changes:
1) Create a param(), not a direct object access. So, instead of
$self->{logger}, I'd use $self->param( 'logger' );
2) Create a logger() method that looks like:
sub logger { $_[0]->param( 'logger' ) }
So, now you have
$self->logger->error( "Uh-oh" );
The overhead is very small compared with the maintenance gains.
Rob
On Tue, 14 Dec 2004 07:30:43 +1300, Dan Horne <suppressed> wrote:
> I currently use Log4Perl with C::A but I'm sure that even though it's not a
> via plugin, I'm using it in an inefficient manner - any advice appreciated.
>
> In my base class, I set up the name of my config file using
> CGI::Application::Plugin::ConfigAuto. I my prerun mode I go
>
> Log::Log4perl::init( $self->cfg('logger_conf') );
> $self->{logger} = get_logger("cms");
>
> So whenever I want to log I go
>
> $self->{logger}->debug("my debug message");
> $self->{logger}->error("uh oh");
>
> Is the way I am doing things expensive? I guess I don't get lazy loading,
> but then again, log messages are sprinkled everywhere, so maybe lazy loading
> is of no advantage to me. To be honest, I've used almost every C::A plugin
> out there, under the assumption that the plugin is going to do things more
> efficiently for me than using the underlying (config, dbh, session) packages
> directly. In other words I use them because I think I should, without
> knowing why (other than the advantage of lazy loading). For instance, if
> there was a C::A::P::Log4Perl plugin, what would be the benefits?
>
> (On a side note, I must say that I really love Log4Perl and use it
> everywhere. I like the way I can change the logging method to screen, db,
> email or all three in the config file without a single change in my code,
> and I also like the way it can use Log::Dispatch modules like
> Log::Dispatch::FileRotate - which has suddenly made half of my log file
> housekeeping scripts redundant). Because I use Oracle a lot for my work I'm
> planning to use Log4PLSQL (their stored procedure language) so that I can
> get a consistent logging idiom throughout my apps (and am trying to
> encourage the other developers to use log4net and log4j - but it may be an
> uphill battle on that one...)
>
> Dan
>
>
>
>
> -----Original Message-----
> From: news [mailto:suppressed On Behalf Of Mark Stosberg
> Sent: Tuesday, 14 December 2004 6:31 a.m.
> To: suppressed
> Subject: [cgiapp] Re: ANNOUNCE: CGI::Application::Plugin::LogDispatch
>
> On 2004-12-13, Cees Hek <suppressed> wrote:
> > On Mon, 13 Dec 2004 10:32:43 +0900, Thilo Planz <suppressed>
> > wrote:
> >> > I finally got around to wrapping up my Log::Dispatch plugin for
> >> > CGI::App. I would appreciate some feedback on the features, and
> >> > what can be done to improve it.
> >>
> >> I think I like it.
> >> I did not know about Log::Dispatch before, just Log4Perl, which
> >> seemed a little too complex for my needs.
> >
> > That was one of my main reasons for moving to Log::Dispatch.
>
> Cees,
>
> Could you elaborate a little on Log::Dispatch vs Log4Perl? I researched the
> options in the past and settled on Log4Perl.
>
> However, I never got over the initial frustrations of getting to know
> Log4Perl stage, and went back to using no formal solution. I still had the
> sense that Log4Perl had all the feature I wanted, but the effort to use it
> effectively was more than I wanted to invest, I think.
>
> Having a CGI::App plug-in is certainly one reason to choose Log::Dispatch.
> :)
>
> Mark
>
> ---------------------------------------------------------------------
> Web Archive: http://www.mail-archive.com/suppressed/
> http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
> To unsubscribe, e-mail: suppressed
> For additional commands, e-mail: suppressed
>
> ---------------------------------------------------------------------
> Web Archive: http://www.mail-archive.com/suppressed/
> http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
> To unsubscribe, e-mail: suppressed
> For additional commands, e-mail: suppressed
>
>
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.