sbekman     01/06/21 00:56:18

  Modified:    Apache-Test/lib/Apache TestTrace.pm
  Log:
  advise on localizing globals overriding
  
  Revision  Changes    Path
  1.3       +26 -16    modperl-2.0/Apache-Test/lib/Apache/TestTrace.pm
  
  Index: TestTrace.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/Apache-Test/lib/Apache/TestTrace.pm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestTrace.pm      2001/06/21 07:52:11     1.2
  +++ TestTrace.pm      2001/06/21 07:56:17     1.3
  @@ -111,22 +111,28 @@
       # demo the trace subs using default setting
       test();
   
  -    # override the default trace level with 'crit'
  -    $Apache::TestTrace::Level = 'crit';
  -    # now only 'crit' and higher levels will do tracing lower level
  -    test();
  -
  -    # set the trace level to 'debug'
  -    $Apache::TestTrace::Level = 'debug';
  -    # now only 'debug' and higher levels will do tracing lower level
  -    test();
  -
  -    open OUT, ">/tmp/foo" or die $!;
  -    # override the default Log filehandle
  -    $Apache::TestTrace::LogFH = \*OUT;
  -    # now the traces will go into a new filehandle
  -    test();
  -    close OUT;
  +    {
  +        # override the default trace level with 'crit'
  +        local $Apache::TestTrace::Level = 'crit';
  +        # now only 'crit' and higher levels will do tracing lower level
  +        test();
  +    }
  +
  +    {
  +        # set the trace level to 'debug'
  +        local $Apache::TestTrace::Level = 'debug';
  +        # now only 'debug' and higher levels will do tracing lower level
  +        test();
  +    }
  +
  +    {
  +        open OUT, ">/tmp/foo" or die $!;
  +        # override the default Log filehandle
  +        local $Apache::TestTrace::LogFH = \*OUT;
  +        # now the traces will go into a new filehandle
  +        test();
  +        close OUT;
  +    }
   
   =head1 DESCRIPTION
   
  @@ -162,6 +168,10 @@
   By default all the output generated by these functions goes to
   STDERR. You can override the default filehandler by overriding
   C<$Apache::TestTrace::LogFH> with a new filehandler.
  +
  +When you override this package's global variables, think about
  +localizing your local settings, so it won't affect other modules using
  +this module in the same run.
   
   =head1 TODO
   
  
  
  

Reply via email to