cvsuser 04/05/14 09:06:38
Modified: App-Context/lib App.pm
Log:
clean up and unify debug/trace scopes
Revision Changes Path
1.12 +45 -20 p5ee/App-Context/lib/App.pm
Index: App.pm
===================================================================
RCS file: /cvs/public/p5ee/App-Context/lib/App.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -w -r1.11 -r1.12
--- App.pm 27 Feb 2004 14:25:10 -0000 1.11
+++ App.pm 14 May 2004 16:06:38 -0000 1.12
@@ -1,6 +1,6 @@
#############################################################################
-## $Id: App.pm,v 1.11 2004/02/27 14:25:10 spadkins Exp $
+## $Id: App.pm,v 1.12 2004/05/14 16:06:38 spadkins Exp $
#############################################################################
package App;
@@ -248,16 +248,18 @@
=head2 Global Variables
- * Global Variable: $App::DEBUG integer
+ * 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::debug_scope scope for debug output
=cut
if (!defined $App::DEBUG) {
+ %App::scope = ();
+ $App::trace = 0;
$App::DEBUG = 0;
$App::DEBUG_FILE = "";
- %App::debug_scope = ();
}
#################################################################
@@ -266,20 +268,44 @@
# 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)
+# -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)
{
- my ($debug, $pkg);
- $debug = $App::options{debug};
- if (defined $debug && $debug ne "") {
+ my $scope = $App::options{scope} || "";
+
+ my $trace = $App::options{trace};
+ if ($trace) {
+ if ($trace =~ s/^([0-9]+),?//) {
+ $App::trace = $1;
+ }
+ else {
+ $App::trace = 9;
+ }
+ }
+ if ($trace) {
+ $scope .= "," if ($scope);
+ $scope .= $trace;
+ }
+
+ my $debug = $App::options{debug};
+ if ($debug) {
if ($debug =~ s/^([0-9]+),?//) {
$App::DEBUG = $1;
}
+ else {
+ $App::DEBUG = 9;
+ }
+ }
if ($debug) {
- foreach $pkg (split(/,/,$debug)) {
- $App::debug_scope{$pkg} = 1;
+ $scope .= "," if ($scope);
+ $scope .= $debug;
}
+
+ if (defined $scope && $scope ne "") {
+ foreach my $pkg (split(/,/,$scope)) {
+ $App::scope{$pkg} = 1;
}
}
@@ -290,11 +316,6 @@
}
open(App::DEBUG_FILE, $debug_file);
}
-
- $App::trace = 0;
- if (defined $App::options{trace}) {
- $App::trace = $App::options{trace};
- }
}
#############################################################################
@@ -733,6 +754,8 @@
}
}
+ return if (%App::scope && !$App::scope{$package} &&
!$App::scope{"$package.$sub"});
+
if ($method) {
if (ref($obj)) { # dynamic method, called on an object
if ($obj->isa("App::Service")) {
@@ -796,7 +819,6 @@
sub sub_exit {
if ($App::trace) {
- $calldepth--;
my ($stacklevel, $calling_package, $file, $line, $subroutine, $hasargs,
$wantarray);
$stacklevel = 1;
($calling_package, $file, $line, $subroutine, $hasargs, $wantarray) =
caller($stacklevel);
@@ -812,6 +834,9 @@
$sub = $2;
}
+ return if (%App::scope && !$App::scope{$package} &&
!$App::scope{"$package.$sub"});
+
+ $calldepth--;
print "| " x $calldepth, "+-> $sub()";
my ($narg, $arg);
for ($narg = 0; $narg <= $#_; $narg++) {