CGI::Builder::LogDispatch - integrated logging system for CGI::Builder
CGI::Builder >= 1.12 Log::Dispatch >= 2.0
# just include it in your build use CGI::Builder qw| CGI::Builder::LogDispatch |; # Logger can write to different "Log Levels". The default level is # "warning". Messages of lesser importance will not be written. When # developing, you probably want this cranked to "debug": sub OH_init { my ($webapp) = @_; # This MUST be done before calling $webapp->logger or it will have no effect! $webapp->logger_config('min_level' => 'debug'); } # Then use it to write nicely formatted messages to your web server log sub PH_AUTOLOAD { my ($webapp) = @_; # The default min_level $webapp->logger->debug("This message only gets logged if you set min_level=>debug."); if ( $webapp->page_error ) { $webapp->logger->error("Oh no! There is a problem!"); } }
The module should do what you want with no prodding. Just include it and start using the logger property to log things. If you are using Apache::CGI::Builder and Apache::Log, it will automatically use Apache's native log mechanism. Otherwise it prints log messages to STDERR (which goes to the web server error log), prepending them with a timestamp.
If you want to do anything fancier than this you can override the logger_new method in your build to construct the object any way you like. See Log::Dispatch for details.
Support is provided via the CGI::Builder Users mailing list. You can join the CBF mailing list at this url:
http://lists.sourceforge.net/lists/listinfo/cgi-builder-users
Many thanks to Domizio Demichelis, author of the CGI::Builder framework, and Dave Rolsky, author of Log::Dispatch.
Vince Veselosky (http://control-escape.com)
(c) 2005 by Vincent Veselosky
This module is free software. It may be used, redistributed and/or modified under the same terms as perl itself.
To install CGI::Builder::LogDispatch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CGI::Builder::LogDispatch
CPAN shell
perl -MCPAN -e shell install CGI::Builder::LogDispatch
For more information on module installation, please visit the detailed CPAN module installation guide.