cvs commit: p5ee/App-Context/lib App.pm

[email protected] (Stephen Adkins)
Newsgroups perl.cvs.p5ee
Message-ID <[email protected]>
cvsuser     05/09/27 09:53:23

  Modified:    App-Context/lib App.pm
  Log:
  trace and debug scopes can now be exclusive (i.e. --trace=!App::Context,App::Context::Cmd)
  
  Revision  Changes    Path
  1.16      +29 -11    p5ee/App-Context/lib/App.pm
  
  Index: App.pm
  ===================================================================
  RCS file: /cvs/public/p5ee/App-Context/lib/App.pm,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- App.pm	5 Apr 2005 18:51:41 -0000	1.15
  +++ App.pm	27 Sep 2005 16:53:23 -0000	1.16
  @@ -248,15 +248,17 @@
   
   =head2 Global Variables
   
  - * Global Variable: %App::scope       scope for debug or tracing output
  - * Global Variable: %App::trace       trace level
  - * Global Variable: $App::DEBUG       debug level
  - * Global Variable: $App::DEBUG_FILE  file for debug output
  + * Global Variable: %App::scope              scope for debug or tracing output
  + * Global Variable: $App::scope_exclusive    flag saying that the scope is exclusive (a list of things *not* to debug/trace)
  + * Global Variable: %App::trace              trace level
  + * Global Variable: $App::DEBUG              debug level
  + * Global Variable: $App::DEBUG_FILE         file for debug output
   
   =cut
   
   if (!defined $App::DEBUG) {
       %App::scope = ();
  +    $App::scope_exclusive = 0;
       $App::trace = 0;
       $App::DEBUG = 0;
       $App::DEBUG_FILE = "";
  @@ -267,11 +269,16 @@
   #################################################################
   
   # Supports the following command-line usage:
  -#    -debug=1                                      (global debug)
  -#    -debug=9                                      (detail debug)
  -#    -scope=App::Context                       (debug class only)
  -#    -scope=App::Context,App::Session          (multiple classes)
  -#    -scope=App::Repository::DBI.select_rows     (indiv. methods)
  +#    --debug=1                                     (global debug)
  +#    --debug=9                                     (detail debug)
  +#    --scope=App::Context                      (debug class only)
  +#    --scope=!App::Context             (debug all but this class)
  +#    --scope=App::Context,App::Session         (multiple classes)
  +#    --scope=App::Repository::DBI.select_rows    (indiv. methods)
  +#    --trace=App::Context                      (trace class only)
  +#    --trace=!App::Context             (trace all but this class)
  +#    --trace=App::Context,App::Session         (multiple classes)
  +#    --trace=App::Repository::DBI.select_rows    (indiv. methods)
   {
       my $scope = $App::options{scope} || "";
   
  @@ -304,6 +311,10 @@
           $scope .= $debug;
       }
   
  +    if ($scope =~ s/^!//) {
  +        $App::scope_exclusive = 1;
  +    }
  +
       if (defined $scope && $scope ne "") {
           foreach my $pkg (split(/,/,$scope)) {
               $App::scope{$pkg} = 1;
  @@ -757,7 +768,14 @@
               }
           }
   
  -        return if (%App::scope && !$App::scope{$package} && !$App::scope{"$package.$sub"});
  +        if (%App::scope) {
  +            if ($App::scope_exclusive) {
  +                return if ($App::scope{$package} || $App::scope{"$package.$sub"});
  +            }
  +            else {
  +                return if (!$App::scope{$package} && !$App::scope{"$package.$sub"});
  +            }
  +        }
   
           if ($method) {
               if (ref($obj)) {  # dynamic method, called on an object
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.