cvsuser     02/10/25 06:05:17

  Modified:    App-Context/lib App.pm
               App-Context/lib/App Context.pm
  Log:
  moved some debug stuff from Context.pm to App.pm
  
  Revision  Changes    Path
  1.3       +39 -2     p5ee/App-Context/lib/App.pm
  
  Index: App.pm
  ===================================================================
  RCS file: /cvs/public/p5ee/App-Context/lib/App.pm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -w -r1.2 -r1.3
  --- App.pm    18 Sep 2002 02:54:10 -0000      1.2
  +++ App.pm    25 Oct 2002 13:05:17 -0000      1.3
  @@ -1,6 +1,6 @@
   
   #############################################################################
  -## $Id: App.pm,v 1.2 2002/09/18 02:54:10 spadkins Exp $
  +## $Id: App.pm,v 1.3 2002/10/25 13:05:17 spadkins Exp $
   #############################################################################
   
   package App;
  @@ -249,10 +249,47 @@
   =head2 Global Variables
   
    * Global Variable: $App::DEBUG      integer
  + * Global Variable: $App::DEBUGFILE  file for debug output
  + * Global Variable: $App::dbgscope   scope for debug output
   
   =cut
   
  -$App::DEBUG = 0 if (!defined $App::DEBUG);
  +if (!defined $App::DEBUG) {
  +    $App::DEBUG = 0;
  +    $App::dbgscope = ();
  +}
  +
  +#################################################################
  +# DEBUGGING
  +#################################################################
  +
  +# Supports the following command-line usage:
  +#    -debug=1                                      (global debug)
  +#    -debug=1,App::Context                     (debug class only)
  +#    -debug=3,App::Context,App::Session        (multiple classes)
  +#    -debug=6,App::Repository::DBI.select_rows   (indiv. methods)
  +{
  +    my ($debug, $pkg);
  +    $debug = $main::conf{debug};
  +    if (defined $debug && $debug ne "") {
  +        if ($debug =~ s/^([0-9]+),?//) {
  +            $App::DEBUG = $1;
  +        }
  +        if ($debug) {
  +            foreach $pkg (split(/,/,$debug)) {
  +                $App::debugscope{$pkg} = 1;
  +            }
  +        }
  +    }
  +
  +    my $debugfile = $main::conf{debugfile};
  +    if ($debugfile) {
  +        if ($debugfile !~ /^[>|]/) {
  +            $debugfile = ">> $debugfile";
  +        }
  +        open(App::DEBUGFILE, $debugfile);
  +    }
  +}
   
   #############################################################################
   # SUPPORT FOR ASPECT-ORIENTED-PROGRAMMING (AOP)
  
  
  
  1.5       +40 -33    p5ee/App-Context/lib/App/Context.pm
  
  Index: Context.pm
  ===================================================================
  RCS file: /cvs/public/p5ee/App-Context/lib/App/Context.pm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -r1.4 -r1.5
  --- Context.pm        15 Oct 2002 21:58:49 -0000      1.4
  +++ Context.pm        25 Oct 2002 13:05:17 -0000      1.5
  @@ -1,6 +1,6 @@
   
   #############################################################################
  -## $Id: Context.pm,v 1.4 2002/10/15 21:58:49 spadkins Exp $
  +## $Id: Context.pm,v 1.5 2002/10/25 13:05:17 spadkins Exp $
   #############################################################################
   
   package App::Context;
  @@ -192,6 +192,43 @@
           }
       }
   
  +    #################################################################
  +    # DEBUGGING
  +    #################################################################
  +
  +    # Supports the following command-line usage:
  +    #    -debug=1                                      (global debug)
  +    #    -debug=1,App::Context                     (debug class only)
  +    #    -debug=3,App::Context,App::Session        (multiple classes)
  +    #    -debug=6,App::Repository::DBI.select_rows   (indiv. methods)
  +    my ($debug, $pkg);
  +    $debug = $args{debug};
  +    if (defined $debug && $debug ne "") {
  +        if ($debug =~ s/^([0-9]+),?//) {
  +            $App::DEBUG = $1;
  +        }
  +        if ($debug) {
  +            foreach $pkg (split(/,/,$debug)) {
  +                $self->{debugscope}{$pkg} = 1;
  +            }
  +        }
  +    }
  +
  +    my ($debugfile);
  +    $debugfile = "";
  +    $debugfile = $self->{initconf}{debugfile} if (ref($self));
  +    if ($debugfile) {
  +        if ($debugfile !~ /^[>|]/) {
  +            $debugfile = ">> $debugfile";
  +        }
  +        if (open(main::DEBUGFILE, $debugfile)) {
  +            close(main::DEBUGFILE);
  +        }
  +    }
  +    else {
  +        print STDERR "Debug: ", @_, "\n";
  +    }
  +
       my ($conf_class, $session_class);
       %args = %$args;
       $self->{initconf} = \%args;
  @@ -218,28 +255,6 @@
       };
       $self->add_message($@) if ($@);
   
  -    #################################################################
  -    # DEBUGGING
  -    #################################################################
  -
  -    # Supports the following command-line usage:
  -    #    -debug=1                                      (global debug)
  -    #    -debug=1,App::Context                     (debug class only)
  -    #    -debug=3,App::Context,App::Session        (multiple classes)
  -    #    -debug=6,App::Repository::DBI.select_rows   (indiv. methods)
  -    my ($debug, $pkg);
  -    $debug = $args{debug};
  -    if (defined $debug && $debug ne "") {
  -        if ($debug =~ s/^([0-9]+),?//) {
  -            $App::DEBUG = $1;
  -        }
  -        if ($debug) {
  -            foreach $pkg (split(/,/,$debug)) {
  -                $self->{debugscope}{$pkg} = 1;
  -            }
  -        }
  -    }
  -
       if ($App::DEBUG && $self->dbg(2)) {
           my $file = $self->{initconf}->{confFile};
           $self->dbgprint("Conf [$file]: ");
  @@ -1363,16 +1378,8 @@
   
   sub dbgprint {
       my $self = shift;
  -    my ($file);
  -    $file = "";
  -    $file = $self->{initconf}{debugfile} if (ref($self));
  -    if ($file) {
  -        $file = ">> $file" if ($self->{initconf}{debugappend});
  -        local(*FILE);
  -        if (open(main::FILE, $file)) {
  -            print main::FILE $$, ": ", @_, "\n";
  -            close(main::FILE);
  -        }
  +    if (defined main::DEBUGFILE) {
  +        print main::DEBUGFILE $$, ": ", @_, "\n";
       }
       else {
           print STDERR "Debug: ", @_, "\n";
  
  
  


Reply via email to