added support for squishing logs.
Marcus Ramberg [Tue, 27 Sep 2005 08:53:05 +0000 (08:53 +0000)]
Changes
lib/Catalyst/Plugin/Static/Simple.pm

diff --git a/Changes b/Changes
index 90d6e0b..2c22beb 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,7 @@
 Revision history for Perl extension Catalyst::Plugin::Static::Simple
 
+       - Added support for squishing logs, depends on Cat 5.50.
+
 0.08    2005-09-07 18:50:00
         - Added tests for everything except Apache support.
 
index 49bf026..4d7ce68 100644 (file)
@@ -56,6 +56,9 @@ sub dispatch {
     return if ( $c->res->status != 200 );
     
     if ( $c->_static_file ) {
+       if ( $c->config->{static}->{no_logs} ) {
+          if ( $c->log->can('abort') ) { $c->log->abort(1) ; }
+       }
         return $c->_serve_static;
     }
     else {
@@ -69,9 +72,8 @@ sub finalize {
     
     # display all log messages
     if ( $c->config->{static}->{debug} && scalar @{$c->_debug_msg} ) {
-        $c->log->debug( "Static::Simple: Serving " .
-            join( " ", @{$c->_debug_msg} )
-        );
+       $c->log->debug( "Static::Simple: Serving " .
+           join( " ", @{$c->_debug_msg} ) );
     }
     
     # return DECLINED when under mod_perl
@@ -107,6 +109,7 @@ sub setup {
     $c->config->{static}->{mime_types} ||= {};
     $c->config->{static}->{use_apache} ||= 0; 
     $c->config->{static}->{debug} ||= $c->debug;
+    $c->config->{static}->{no_logs} ||= 1;
     
     # load up a MIME::Types object, only loading types with
     # at least 1 file extension
@@ -291,6 +294,13 @@ Configuration is completely optional and is specified within
 MyApp->config->{static}.  If you use any of these options, the module will
 probably feel less "simple" to you!
 
+=head2 Aborting request logging
+
+With Catalyst 5.50, there has been added support for dropping logging for a 
+request. We've turned this on by default, as static logging tends to clutter
+the Log API, however, if you want logging of static requests, you can easily
+turn it on by setting MyApp->config->{static}->{no_logs} to 0.
+
 =head2 Forcing directories into static mode
 
 Define a list of top-level directories beneath your 'root' directory that