On Thu, 03 Feb 2005 23:19:05 +0100, Rhesa Rozendaal <suppressed> wrote:
> Cees,
>
> thank you for adding singleton support! This makes it extremely simple
> to use different loggers throughout my applications, especially under
> mod_perl. But the added bonus - and this was a very pleasant surprise
> for me - is that they function equally well outside of cgi-app!
I'm glad you found it useful. I realized as well that there was no
real dependency on CGI::App after I wrote the module. I couldn't
think of a more generic name that really fit though, and my goal was
to get it to work well with CGI::Application.
> I just created a very simple namespace to add logging by copy/pasting
> stuff from the documentation:
>
> package My::SimpleLog;
> use CGI::Application::Plugin::LogDispatch (
> LOG_DISPATCH_MODULES => [
> { module => 'Log::Dispatch::File',
> name => 'debug',
> filename => /tmp/debug.log',
> mode => '>>',
> min_level => 'debug',
> },
> ],
> APPEND_NEWLINE => 1,
> );
>
> 1;
I quite like that. This nicely keeps your logging config separate
from the other code, while still having it accessible from within any
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 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
could make those functions exportable by request like this:
package My::SimpleLog;
use CGI::Application::Plugin::LogDispatch qw(:logmethods);
My::SimpleLog->log_config(
LOG_DISPATCH_MODULES => [
{ module => 'Log::Dispatch::File',
name => 'debug',
filename => /tmp/debug.log',
mode => '>>',
min_level => 'debug',
},
],
APPEND_NEWLINE => 1,
);
Does that sound reasonable?
Thanks again,
Cees
---------------------------------------------------------------------
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.