[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.6, Mon Mar 7 02:01:51 2005 UTC revision 1.7, Tue Apr 5 05:25:57 2005 UTC
# Line 7  Line 7 
7          use strict;          use strict;
8          use Carp qw(longmess croak);          use Carp qw(longmess croak);
9          use CGI;          use CGI;
10            use FIG_Config;
11            use PageBuilder;
12    
13  =head1 Tracing and Debugging Helpers  =head1 Tracing and Debugging Helpers
14    
# Line 42  Line 44 
44    
45  C<< TSetup('3 errors Sprout ERDB', 'HTML'); >>  C<< TSetup('3 errors Sprout ERDB', 'HTML'); >>
46    
47  sets the trace level to 3, activated the C<errors>, C<Sprout>, and C<ERDB> categories, and  sets the trace level to 3, activates the C<errors>, C<Sprout>, and C<ERDB> categories, and
48  specifies that messages should be output as HTML paragraphs. The idea is to make it easier to  specifies that messages should be output as HTML paragraphs. The parameters are formatted
49  input tracing configuration on a web form.  to make it easier to input tracing configuration on a web form.
50    
51  In addition to HTML and file output for trace messages, you can specify that the trace messages  In addition to HTML and file output for trace messages, you can specify that the trace messages
52  be queued. The messages can then be retrieved by calling the L</QTrace> method. This approach  be queued. The messages can then be retrieved by calling the L</QTrace> method. This approach
# Line 69  Line 71 
71  my $TraceLevel = 0;                     # trace level; a higher trace level produces more  my $TraceLevel = 0;                     # trace level; a higher trace level produces more
72                                                          # messages                                                          # messages
73  my @Queue = ();                         # queued list of trace messages.  my @Queue = ();                         # queued list of trace messages.
74    my $LastCategory = "main";  # name of the last category interrogated
75    
76  =head2 Public Methods  =head2 Public Methods
77    
# Line 371  Line 374 
374          # Get the timestamp.          # Get the timestamp.
375          my $timeStamp = Now();          my $timeStamp = Now();
376          # Format the message.          # Format the message.
377          my $formatted = "$timeStamp $message";          my $formatted = "$timeStamp <$LastCategory>: $message";
378          # Process according to the destination.          # Process according to the destination.
379          if ($Destination eq "TEXT") {          if ($Destination eq "TEXT") {
380                  # Write the message to the standard output.                  # Write the message to the standard output.
# Line 445  Line 448 
448                                  $category = $package;                                  $category = $package;
449                          }                          }
450                  }                  }
451                  # Use the package and tracelevel to compute the result.          # Save the category name.
452            $LastCategory = $category;
453                    # Use the category and tracelevel to compute the result.
454                  $retVal = ($traceLevel <= $TraceLevel && exists $Categories{$category});                  $retVal = ($traceLevel <= $TraceLevel && exists $Categories{$category});
455      }      }
456          # Return the computed result.          # Return the computed result.
# Line 958  Line 963 
963      }      }
964  }  }
965    
966    =head3 DebugMode
967    
968    C<< if (Tracer::DebugMode) { ...code... } >>
969    
970    Return TRUE if debug mode has been turned on in FIG_Config, else output
971    an error page and return FALSE.
972    
973    Certain CGI scripts are too dangerous to exist in the production
974    environment. This method provides a simple way to prevent them
975    from working unless they are explicitly turned on in the configuration
976    file by setting C<$FIG_Config::debug_mode> to 1. If debugging mode
977    is not turned on, an error web page will be output.
978    
979    =cut
980    
981    sub DebugMode {
982            # Declare the return variable.
983            my $retVal;
984            # Check the debug configuration.
985            if ($FIG_Config::debug_mode) {
986                    $retVal = 1;
987            } else {
988                    # Here debug mode is off, so we generate an error page.
989                    my $pageString = PageBuilder::Build(">Html/ErrorPage.html", {}, "Html");
990                    print $pageString;
991            }
992            # Return the determination indicator.
993            return $retVal;
994    }
995    
996  1;  1;

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3