[Bps-public-commit] r16944 - in Path-Dispatcher/trunk: lib/Path/Dispatcher

sartak at bestpractical.com sartak at bestpractical.com
Wed Nov 19 17:23:13 EST 2008


Author: sartak
Date: Wed Nov 19 17:23:13 2008
New Revision: 16944

Modified:
   Path-Dispatcher/trunk/   (props changed)
   Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule.pm

Log:
 r75844 at onn:  sartak | 2008-11-19 17:23:10 -0500
 Trace levels; 2 turns on readable_attributes, 10 turns on deparsing of run blocks


Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule.pm	(original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule.pm	Wed Nov 19 17:23:13 2008
@@ -75,6 +75,11 @@
     my $self  = shift;
     my %args  = @_;
 
+    my $level = $ENV{'PATH_DISPATCHER_TRACE'};
+
+    return if exists($args{level})
+           && $level < $args{level};
+
     my $match = $args{match};
     my $path  = $match ? $match->path->path : $args{path}->path;
 
@@ -88,12 +93,18 @@
     }
 
     # attributes such as tokens or regex
-    my $attr = $self->readable_attributes;
-    $trace .= " $attr" if defined($attr) && length($attr);
+    if ($level >= 2) {
+        my $attr = $self->readable_attributes;
+        $trace .= " $attr" if defined($attr) && length($attr);
+    }
 
     # what just happened
     if ($args{running}) {
         $trace .= " running codeblock with path ($path)";
+        if ($level >= 10) {
+            require B::Deparse;
+            $trace .= ": " . B::Deparse->new->coderef2text($match->rule->block);
+        }
     }
     elsif ($match) {
         $trace .= " matched against ($path)";



More information about the Bps-public-commit mailing list