[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.36, Sun Jan 15 21:27:33 2006 UTC revision 1.39, Fri Feb 24 19:45:29 2006 UTC
# Line 19  Line 19 
19    
20      require Exporter;      require Exporter;
21      @ISA = ('Exporter');      @ISA = ('Exporter');
22      @EXPORT = qw(Trace T TSetup QTrace Confess Cluck Min Max Assert Open OpenDir TICK StandardSetup ScriptSetup ScriptFinish);      @EXPORT = qw(Trace T TSetup QTrace Confess Cluck Min Max Assert Open OpenDir TICK StandardSetup ScriptSetup ScriptFinish Insure);
23      @EXPORT_OK = qw(GetFile GetOptions Merge MergeOptions ParseCommand ParseRecord UnEscape Escape);      @EXPORT_OK = qw(GetFile GetOptions Merge MergeOptions ParseCommand ParseRecord UnEscape Escape);
24      use strict;      use strict;
25      use Carp qw(longmess croak);      use Carp qw(longmess croak);
# Line 28  Line 28 
28      use PageBuilder;      use PageBuilder;
29      use Digest::MD5;      use Digest::MD5;
30      use File::Basename;      use File::Basename;
31        use File::Path;
32    
33  =head1 Tracing and Debugging Helpers  =head1 Tracing and Debugging Helpers
34    
# Line 256  Line 257 
257      TransactFeatures -trace=3 -sql register ../xacts IDs.tbl      TransactFeatures -trace=3 -sql register ../xacts IDs.tbl
258    
259  Standard tracing is output to the standard output and echoed to the file  Standard tracing is output to the standard output and echoed to the file
260  C<trace.log> in the FIG temporary directory.  C<trace>I<$$>C<.log> in the FIG temporary directory, where I<$$> is the
261    process ID. You can also specify the C<user> parameter to put a user ID
262    instead of a process ID in the trace file name. So, for example
263    
264  The default trace level is 2. To get all messages, specify a trace level of 4.  The default trace level is 2. To get all messages, specify a trace level of 4.
265  For a genome-by-genome update, use 3.  For a genome-by-genome update, use 3.
266    
267        TransactFeatures -trace=3 -sql -user=Bruce register ../xacts IDs.tbl
268    
269    would send the trace output to C<traceBruce.log> in the temporary directory.
270    
271  The I<options> parameter is a reference to a hash containing the command-line  The I<options> parameter is a reference to a hash containing the command-line
272  options, their default values, and an explanation of what they mean. Command-line  options, their default values, and an explanation of what they mean. Command-line
273  options may be in the form of switches or keywords. In the case of a switch, the  options may be in the form of switches or keywords. In the case of a switch, the
# Line 370  Line 377 
377      $options->{trace} = [2, "tracing level"];      $options->{trace} = [2, "tracing level"];
378      $options->{sql} = [0, "turn on SQL tracing"];      $options->{sql} = [0, "turn on SQL tracing"];
379      $options->{h} = [0, "display command-line options"];      $options->{h} = [0, "display command-line options"];
380        $options->{user} = [$$, "trace log file name suffix"];
381      # Create a parsing hash from the options hash. The parsing hash      # Create a parsing hash from the options hash. The parsing hash
382      # contains the default values rather than the default value      # contains the default values rather than the default value
383      # and the description. While we're at it, we'll memorize the      # and the description. While we're at it, we'll memorize the
# Line 396  Line 404 
404      # and joining the categories.      # and joining the categories.
405      my $cats = join(" ", $parseOptions{trace}, @cats);      my $cats = join(" ", $parseOptions{trace}, @cats);
406      # Now set up the tracing.      # Now set up the tracing.
407      TSetup($cats, "+>$FIG_Config::temp/trace.log");      my $suffix = $retOptions->{user};
408        TSetup($cats, "+>$FIG_Config::temp/trace$suffix.log");
409      # Check for the "h" option. If it is specified, dump the command-line      # Check for the "h" option. If it is specified, dump the command-line
410      # options and exit the program.      # options and exit the program.
411      if ($retOptions->{h}) {      if ($retOptions->{h}) {
# Line 1286  Line 1295 
1295  =item RETURN  =item RETURN
1296    
1297  In a list context, returns the entire file as a list with the line terminators removed.  In a list context, returns the entire file as a list with the line terminators removed.
1298  In a scalar context, returns the entire file as a string.  In a scalar context, returns the entire file as a string. If an error occurs opening
1299    the file, an empty list will be returned.
1300    
1301  =back  =back
1302    
# Line 1840  Line 1850 
1850  to their values. The template file will be read into memory, and variable markers  to their values. The template file will be read into memory, and variable markers
1851  will be replaced by data in this hash reference.  will be replaced by data in this hash reference.
1852    
1853    =back
1854    
1855  =cut  =cut
1856    
1857  sub ScriptFinish {  sub ScriptFinish {
# Line 1869  Line 1881 
1881      print $outputString;      print $outputString;
1882  }  }
1883    
1884    =head3 Insure
1885    
1886    C<< Insure($dirName); >>
1887    
1888    Insure a directory is present.
1889    
1890    =over 4
1891    
1892    =item dirName
1893    
1894    Name of the directory to check. If it does not exist, it will be created.
1895    
1896    =back
1897    
1898    =cut
1899    
1900    sub Insure {
1901        my ($dirName) = @_;
1902        if (! -d $dirName) {
1903            Trace("Creating $dirName directory.") if T(2);
1904            mkpath $dirName;
1905        }
1906    }
1907    
1908  1;  1;

Legend:
Removed from v.1.36  
changed lines
  Added in v.1.39

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3