cvs commit: p5ee/App-Context/lib App.pm

[email protected] (Stephen Adkins)
Newsgroups perl.cvs.p5ee
Message-ID <[email protected]>
cvsuser     06/02/24 11:45:34

  Modified:    App-Context/lib App.pm
  Log:
  made trace behave better with newlines. added trace_justify.
  
  Revision  Changes    Path
  1.19      +19 -5     p5ee/App-Context/lib/App.pm
  
  Index: App.pm
  ===================================================================
  RCS file: /cvs/public/p5ee/App-Context/lib/App.pm,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- App.pm	20 Oct 2005 19:40:39 -0000	1.18
  +++ App.pm	24 Feb 2006 19:45:34 -0000	1.19
  @@ -296,6 +296,7 @@
           $scope .= $trace;
       }
       $App::trace_width = (defined $App::options{trace_width}) ? $App::options{trace_width} : 1024;
  +    $App::trace_justify = (defined $App::options{trace_justify}) ? $App::options{trace_justify} : 0;
   
       my $debug = $App::options{debug};
       if ($debug) {
  @@ -824,10 +825,22 @@
           #$trailer .= " [package=$package sub=$sub subroutine=$subroutine class=$class method=$method]";
           $text .= ")";
           my $trailer_len = length($trailer);
  -        if ($App::trace_width && length($text) + $trailer_len > $App::trace_width) {
  -            my $len = $App::trace_width - $trailer_len;
  -            $len = 1 if ($len < 1);
  -            print substr($text, 0, $len), $trailer, "\n";
  +        $text =~ s/\n/\\n/g;
  +        my $text_len = length($text);
  +        if ($App::trace_width) {
  +            if ($text_len + $trailer_len > $App::trace_width) {
  +                my $len = $App::trace_width - $trailer_len;
  +                $len = 1 if ($len < 1);
  +                print substr($text, 0, $len), $trailer, "\n";
  +            }
  +            elsif ($App::trace_justify) {
  +                my $len = $App::trace_width - $trailer_len - $text_len;
  +                $len = 0 if ($len < 0);  # should never happen
  +                print $text, ("." x $len), $trailer, "\n";
  +            }
  +            else {
  +                print $text, $trailer, "\n";
  +            }
           }
           else {
               print $text, $trailer, "\n";
  @@ -889,6 +902,7 @@
                   $text .= $arg;
               }
           }
  +        $text =~ s/\n/\\n/g;
           if ($App::trace_width && length($text) > $App::trace_width) {
               print substr($text, 0, $App::trace_width), "\n";
           }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.