Cees Hek wrote:
module.  You could save a bit of type by copying the logging functions
into this namespace as well.  Something like this:

foreach my $func (qw(debug info notice warning error critical alert
emergency)) {
  *$func = sub { __PACKAGE__->log->$func(@_) };
}

Now you can just call My::SimpleLog->debug('testing');

I like that a lot, yes, for scripts outside of cgi-app.

I think I would only use something like that if creating a custom
namespace purely for logging like you have done here.  I don't think I
would import all those functions into my CGI::App modules as it gets a
bit too busy in the namespace.  But here it seems a nice fit.  Maybe I

I agree.

could make those functions exportable by request like this:

package My::SimpleLog;
use CGI::Application::Plugin::LogDispatch qw(:logmethods);

Does that sound reasonable?

Very much so! I'd love to see it in there, given that it's so simple.

I have one question (quite likely off topic), and that is: how do you turn off all logging except for errors? I assume you simply remove the loggers for a specific level?
I read something in the Log4perl docs that said you could make certain logging calls no-ops, but didn't see anything like that in the LogDispatch docs. It sounds like a very efficient method (especially the tip to wrap the arguments to the log call in an anonymous sub, which could potentially save time), and I wonder if this is possible with LogDispatch as well.


Rhesa

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to