Author: timbo
Date: Fri Jun 15 09:14:54 2007
New Revision: 9656

Modified:
   dbi/trunk/lib/DBI/Profile.pm

Log:
Add format_path_element to DBI::Profile as_text()


Modified: dbi/trunk/lib/DBI/Profile.pm
==============================================================================
--- dbi/trunk/lib/DBI/Profile.pm        (original)
+++ dbi/trunk/lib/DBI/Profile.pm        Fri Jun 15 09:14:54 2007
@@ -800,6 +800,8 @@
 sub as_text {
     my ($self, $args_ref) = @_;
     my $separator = $args_ref->{separator} || " > ";
+    my $format_path_element = $args_ref->{format_path_element}
+        || "%s"; # or e.g., " key%2$d='%s'"
     my $format    = $args_ref->{format}
         || '%1$s: %11$fs / %10$d = %2$fs avg (first %12$fs, min %13$fs, max 
%14$fs)'."\n";
     
@@ -813,11 +815,14 @@
     my @text;
     for my $node_path (@node_path_list) {
         my ($node, @path) = @$node_path;
-        s/[\r\n]+/ /g for @path;
-        s/$separator_re/ /g for @path;
-        my $path_str = join($separator, @path);
+        my $idx = 0;
+        for (@path) {
+            s/[\r\n]+/ /g;
+            s/$separator_re/ /g;
+            $_ = sprintf $format_path_element, $_, ++$idx;
+        }
         push @text, sprintf $format,
-            $path_str,                                # 1=path
+            join($separator, @path),                  # 1=path
             ($node->[0] ? $node->[4]/$node->[0] : 0), # 2=avg
             (undef) x 7,                              # spare slots
             @$node; # 10=count, 11=dur, 12=first_dur, 13=min, 14=max, 
15=first_called, 16=last_called

Reply via email to