[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.97, Tue Apr 29 06:01:21 2008 UTC revision 1.98, Thu May 1 07:52:10 2008 UTC
# Line 274  Line 274 
274          }          }
275      }      }
276      # Now we need to process the destination information. The most important special      # Now we need to process the destination information. The most important special
277      # cases are the single ">", which requires we clear the file first, and the      # case is when we're writing to a file. This is indicated by ">" (overwrite) and
278      # "+" prefix which indicates a double echo.      # ">>" (append). A leading "+" for either indicates that we are also writing to
279        # the standard output (tee mode).
280      if ($target =~ m/^\+?>>?/) {      if ($target =~ m/^\+?>>?/) {
281          if ($target =~ m/^\+/) {          if ($target =~ m/^\+/) {
282              $TeeFlag = 1;              $TeeFlag = 1;
283              $target = substr($target, 1);              $target = substr($target, 1);
284          }          }
285          if ($target =~ m/^>[^>]/) {          if ($target =~ m/^>[^>]/) {
286                # We need to initialize the file (which clears it).
287              open TRACEFILE, $target;              open TRACEFILE, $target;
288              print TRACEFILE "[" . Now() . "] [Tracer] Tracing initialized.\n";              print TRACEFILE "[" . Now() . "] [notice] [Tracer] Tracing initialized.\n";
289              close TRACEFILE;              close TRACEFILE;
290                # Set to append mode now that the file has been cleared.
291              $Destination = ">$target";              $Destination = ">$target";
292          } else {          } else {
293              $Destination = $target;              $Destination = $target;
# Line 453  Line 456 
456      my ($callPackage, $callFile, $callLine) = caller();      my ($callPackage, $callFile, $callLine) = caller();
457      my $callFileTitle = basename($callFile);      my $callFileTitle = basename($callFile);
458      # Check the caller.      # Check the caller.
459      if ($callFileTitle ne "Tracer\.pm") {      my $callerInfo = ($callFileTitle ne "Tracer.pm" ? " [$callFileTitle $callLine]" : "");
         # The caller isn't us, so add the caller info to the message.  
         $stripped = "[$callFileTitle $callLine] $stripped";  
     }  
460      # Get the timestamp.      # Get the timestamp.
461      my $timeStamp = Now();      my $timeStamp = Now();
462      # Build the prefix.      # Build the prefix.
463      my $level = $LevelNames[$LastLevel] || "($LastLevel)";      my $level = $LevelNames[$LastLevel] || "($LastLevel)";
464      my $prefix = "[$timeStamp] [$level] ";      my $prefix = "[$timeStamp] [$level] [$LastCategory]$callerInfo";
465      # Format the message.      # Format the message.
466      my $formatted = "$prefix $stripped";      my $formatted = "$prefix $stripped";
467      # Process according to the destination.      # Process according to the destination.
# Line 473  Line 473 
473          print STDERR "$formatted\n";          print STDERR "$formatted\n";
474      } elsif ($Destination eq "WARN") {      } elsif ($Destination eq "WARN") {
475          # Emit the message to the standard error output. It is presumed that the          # Emit the message to the standard error output. It is presumed that the
476          # error logger will add its own prefix fields          # error logger will add its own prefix fields, the notable exception being
477          print STDERR "$stripped\n";          # the caller info.
478            print STDERR "$callerInfo$stripped\n";
479      } elsif ($Destination eq "QUEUE") {      } elsif ($Destination eq "QUEUE") {
480          # Push the message into the queue.          # Push the message into the queue.
481          push @Queue, "$formatted";          push @Queue, "$formatted";
# Line 1605  Line 1606 
1606              # Close the test file.              # Close the test file.
1607              close TESTTRACE;              close TESTTRACE;
1608          } else {          } else {
1609              # Here we can't trace to a file. We trace to the standard output if it's              # Here we can't trace to a file. Complain about this.
1610                warn "Could not open trace file $traceFileName: $!\n";
1611                # We trace to the standard output if it's
1612              # okay, and the error log otherwise.              # okay, and the error log otherwise.
1613              if ($textOKFlag) {              if ($textOKFlag) {
1614                  $traceMode = "TEXT";                  $traceMode = "TEXT";

Legend:
Removed from v.1.97  
changed lines
  Added in v.1.98

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3