[Catalyst] Selective debug output

Karim Nassar karim.nassar at acm.org
Wed Nov 7 19:55:52 GMT 2007


If debugging via plugin is going to be added, it'd be super sweet if there
were support for full logging.

At my former employer, we had a logging infrastructure, but it had to work
with more than just catalyst, so it was not optimal.

I feel what is needed is the ability to log in any module such that I can
debug/log at will, and not have to worry about removing debug statements:

MyApp->config(
    default_log_level =3D> 'info+'
    <module> =3D> { log_level =3D <LOG_LEVEL> }
);

Then later:
package MyApp::M::Module;
sub whatever {
  # $c not usually available in Model
  MyApp::M::Module::log("static call here!");
}

More later:
package MyApp::C::Module;
sub whatever : Local {
  my ($self, $c) =3D @_;
  $self->log('OO Call here!');
}

We supported standard log levels:

debug
info
notice
warning
error
critical
alert
emergency

This technique would allow you to pick and choose which messages you wanted
to see, such that all of these were valid log level settings:

warning+
debug,warning,error
critical,emergency
info+

In a production environment, it'd be nice to be able to send certain log
levels through other channels as well i.e.: alternate log files or some
monitoring program's mechanism, but having the rest in place first is
extremely nice during development, and makes site monitoring easier.

--Karim Nassar

On 11/7/07, Christopher H. Laco <claco at chrislaco.com> wrote:
>
> J. Shirley wrote:
> > On Nov 6, 2007 5:47 PM, Jonathan Rockway <jon at jrock.us> wrote:
> >
> >> Joe Landman wrote:
> >>> How do I selectively enable or disable debugging output?
> >>> Specifically, FormBuilder debugging output is simply far to verbose to
> >>> be meaningful to us.  I suppose I could simply pass in a debug=3D>0 w=
hen
> >>> I create the form.  Is there any global way?
> >>>
> >>> FWIW:  I only want to surpress formbuilder output during debug.
> >> Unfortunately there is no way to do what you want.  Most of the plugins
> >> (etc.) just check $c->debug to see whether or not to log via
> >> $c->log->debug.  I suggest a filter in a custom log class (just regex
> >> the formbuilder crap out), or fixing the plugins/controllers to check
> >> $c->config->{pluginname_debug) or something.  Maybe we can make this
> >> easier in 5.8; suggestions welcome.
> >>
> >> Regards,
> >> Jonathan Rockway
> >>
> >>
> >>
> >>
> >>
> > I would prefer something like:
> > MyApp->config(
> >     'PluginName' =3D> { debug =3D 0 }
> > );
> >
> > Thoughts?
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > List: Catalyst at lists.scsys.co.uk
> > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> > Searchable archive:
> http://www.mail-archive.com/catalyst@lists.rawmode.org/
> > Dev site: http://dev.catalyst.perl.org/
>
> On a somewhat related note.
> While writing REST tests thius weekend, I set CATALYST_DEBUG=3D0, yet
> C::A::REST insisted on debugging anyway. I guess I never realized that
> you always have to check $c->debug first, and assumed $c->log->debug
> would go to the bit bucket if CATALYST_DEBUG was false.
>
> In my case, I just cheated, and had MyApp::debug do the check first to
> squelch all of the non believers.
>
> -=3DChris
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20071107/9482b=
ea1/attachment.htm


More information about the Catalyst mailing list