[Catalyst-commits] r7559 - in trunk/Catalyst-Plugin-StackTrace: .
lib/Catalyst/Plugin t
ash at dev.catalyst.perl.org
ash at dev.catalyst.perl.org
Fri Apr 4 16:10:50 BST 2008
Author: ash
Date: 2008-04-04 16:10:44 +0100 (Fri, 04 Apr 2008)
New Revision: 7559
Modified:
trunk/Catalyst-Plugin-StackTrace/Changes
trunk/Catalyst-Plugin-StackTrace/lib/Catalyst/Plugin/StackTrace.pm
trunk/Catalyst-Plugin-StackTrace/t/04trace.t
Log:
C<enable> config var to force on or off the stacktrace functionality
Modified: trunk/Catalyst-Plugin-StackTrace/Changes
===================================================================
--- trunk/Catalyst-Plugin-StackTrace/Changes 2008-04-04 15:01:59 UTC (rev 7558)
+++ trunk/Catalyst-Plugin-StackTrace/Changes 2008-04-04 15:10:44 UTC (rev 7559)
@@ -1,5 +1,8 @@
Revision history for Perl extension Catalyst::Plugin::StackTrace
+0.08 2008-04-04 16:30:00
+ - Allow enabling functionality by config variable
+
0.07 2008-02-01 13:00:00
- actually, the $@ reset is fairly general - need to die($error)
no matter what.
Modified: trunk/Catalyst-Plugin-StackTrace/lib/Catalyst/Plugin/StackTrace.pm
===================================================================
--- trunk/Catalyst-Plugin-StackTrace/lib/Catalyst/Plugin/StackTrace.pm 2008-04-04 15:01:59 UTC (rev 7558)
+++ trunk/Catalyst-Plugin-StackTrace/lib/Catalyst/Plugin/StackTrace.pm 2008-04-04 15:10:44 UTC (rev 7559)
@@ -9,7 +9,7 @@
use Scalar::Util qw/blessed/;
use NEXT;
-our $VERSION = '0.07';
+our $VERSION = '0.08';
__PACKAGE__->mk_accessors('_stacktrace');
@@ -19,8 +19,12 @@
# NEXT hack is required when extending execute :(
local $NEXT::NEXT{ $c, 'execute' };
- return $c->NEXT::execute(@_) unless $c->debug;
+ my $conf = $c->config->{stacktrace};
+ return $c->NEXT::execute(@_)
+ unless defined $conf->{enable} && $conf->{enable}
+ || !defined $conf->{enable} && $c->debug;
+
local $SIG{__DIE__} = sub {
my $error = shift;
@@ -226,12 +230,18 @@
Each stack frame is displayed along with the package name, line number, file
name, and code context surrounding the line number.
-This plugin is only active in -Debug mode.
+This plugin is only active in -Debug mode by default, but can be enabled by
+setting the C<enable> config option.
=head1 CONFIGURATION
Configuration is optional and is specified in MyApp->config->{stacktrace}.
+=head2 enable
+
+Allows you forcibly enable or disalbe this plugin, ignoring the current
+debug setting. If this option is defined, its value will be used.
+
=head2 context
The number of context lines of code to display on either side of the stack
Modified: trunk/Catalyst-Plugin-StackTrace/t/04trace.t
===================================================================
--- trunk/Catalyst-Plugin-StackTrace/t/04trace.t 2008-04-04 15:01:59 UTC (rev 7558)
+++ trunk/Catalyst-Plugin-StackTrace/t/04trace.t 2008-04-04 15:10:44 UTC (rev 7559)
@@ -7,7 +7,7 @@
use lib "$FindBin::Bin/lib";
use Test::More;
-plan tests => 7;
+plan tests => 10;
use Catalyst::Test 'TestApp';
open STDERR, '>/dev/null';
@@ -27,3 +27,10 @@
like( $res->content, qr{<strong class="line"> 30: three()}, 'context ok' );
}
+TestApp->config->{stacktrace}{enable} = 0;
+
+{
+ ok( my $res = request('http://localhost/foo/not_ok'), 'request ok' );
+ like( $res->content, qr{Caught exception.+TestApp::Controller::Foo::three}, 'error ok' );
+ unlike( $res->content, qr{Stack Trace}, 'trace disable' );
+}
More information about the Catalyst-commits
mailing list