[Bio] / FigKernelPackages / Tracer.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/Tracer.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.93, Tue Feb 5 02:17:29 2008 UTC revision 1.94, Tue Mar 11 21:04:56 2008 UTC
# Line 284  Line 284 
284    
285  # Declare the configuration variables.  # Declare the configuration variables.
286    
287  my $Destination = "NONE";   # Description of where to send the trace output.  my $Destination = "WARN";   # Description of where to send the trace output.
288  my $TeeFlag = 0;            # TRUE if output is going to a file and to the  my $TeeFlag = 0;            # TRUE if output is going to a file and to the
289                              # standard output                              # standard output
290  my %Categories = ( main => 1 );  my %Categories = ( main => 1 );
# Line 849  Line 849 
849      }      }
850      # Setup the tracing we've determined from all the stuff above.      # Setup the tracing we've determined from all the stuff above.
851      TSetup($tracing, $dest);      TSetup($tracing, $dest);
852      # If we're a web script, trace the parameter and environment data.      # Check to see if we're a web script.
853      if (defined $cgi) {      if (defined $cgi) {
854            # Yes we are. Trace the form and environment data.
855          TraceParms($cgi);          TraceParms($cgi);
856            # Check for RAW mode. In raw mode, we print a fake header so that we see everything
857            # emitted by the script in its raw form.
858            if (T(Raw => 3)) {
859                print CGI::header(-type => 'text/plain', -tracing => 'Raw');
860            }
861      }      }
862  }  }
863    
# Line 1062  Line 1068 
1068      Tracer::TraceParms($cgi);      Tracer::TraceParms($cgi);
1069    
1070  Trace the CGI parameters at trace level CGI => 3 and the environment variables  Trace the CGI parameters at trace level CGI => 3 and the environment variables
1071  at level CGI => 4.  at level CGI => 4. A self-referencing URL is traced at level CGI => 2.
1072    
1073  =over 4  =over 4
1074    
# Line 1077  Line 1083 
1083  sub TraceParms {  sub TraceParms {
1084      # Get the parameters.      # Get the parameters.
1085      my ($cgi) = @_;      my ($cgi) = @_;
1086        if (T(CGI => 2)) {
1087            # Here we trace the GET-style URL for the script.
1088            Trace("URL: " . $cgi->url(-relative => 1, -query => 1));
1089        }
1090      if (T(CGI => 3)) {      if (T(CGI => 3)) {
1091          # Here we want to trace the parameter data.          # Here we want to trace the parameter data.
1092          my @names = $cgi->param;          my @names = $cgi->param;
# Line 1099  Line 1109 
1109      }      }
1110  }  }
1111    
1112    =head3 TraceImages
1113    
1114        Tracer::TraceImages($htmlString);
1115    
1116    Trace information about all of an html document's images. The tracing
1117    will be for type "IMG" at level 3. The image's source string
1118    will be displayed. This is generally either the URL of the image or
1119    raw data for the image itself. If the source is too long, only the first 300
1120    characters will be shown at trace level 3. The entire source will be shown,
1121    however, at trace level 4. This method is not very smart, and might catch
1122    Javascript code, but it is still useful when debugging the arcane
1123    behavior of images in multiple browser environments.
1124    
1125    =over 4
1126    
1127    =item htmlString
1128    
1129    HTML text for an outgoing web page.
1130    
1131    =back
1132    
1133    =cut
1134    
1135    sub TraceImages {
1136        # Only proceed if we're at the proper trace level.
1137        if (T(IMG => 3)) {
1138            # For performance reasons we're manipulating $_[0] instead of retrieving the string
1139            # into a variable called "$htmlString". This is because we expect html strings to be
1140            # long, and don't want to copy them any more than we have to.
1141            Trace(length($_[0]) . " characters in web page.");
1142            # Loop through the HTML, culling image tags.
1143            while ($_[0] =~ /<img\s+[^>]+?src="([^"]+)"/sgi) {
1144                # Extract the source string and determine whether or not it's too long.
1145                my $srcString = $1;
1146                my $pos = pos($_[0]) - length($srcString);
1147                my $excess = length($srcString) - 300;
1148                # We'll put the display string in here.
1149                my $srcDisplay = $srcString;
1150                # If it's a data string, split it at the comma.
1151                $srcDisplay =~ s/^(data[^,]+,)/$1\n/;
1152                # If there's no excess or we're at trace level 4, we're done. At level 3 with
1153                # a long string, however, we only show the first 300 characters.
1154                if ($excess > 0 && ! T(IMG => 4)) {
1155                    $srcDisplay = substr($srcDisplay,0,300) . "\nplus $excess characters.";
1156                }
1157                # Output the trace message.
1158                Trace("Image tag at position $pos:\n$srcDisplay");
1159            }
1160        }
1161    }
1162    
1163    
1164  =head3 ScriptFinish  =head3 ScriptFinish
1165    
1166      ScriptFinish($webData, $varHash);      ScriptFinish($webData, $varHash);

Legend:
Removed from v.1.93  
changed lines
  Added in v.1.94

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3