Author: spadkins
Date: Fri Jun 22 14:00:38 2007
New Revision: 9669
Modified:
p5ee/trunk/App-Context/lib/App.pm
p5ee/trunk/App-Context/lib/App/Context.pm
Log:
add sup****t for the --debug_file option which redirects the output for
--trace, --debug, --debug_sql, etc.
Modified: p5ee/trunk/App-Context/lib/App.pm
==============================================================================
--- p5ee/trunk/App-Context/lib/App.pm (original)
+++ p5ee/trunk/App-Context/lib/App.pm Fri Jun 22 14:00:38 2007
@[EMAIL PROTECTED]
-267,7 +267,6 @[EMAIL PROTECTED]
$App::scope_exclusive = 0;
$App::trace = 0;
$App::DEBUG = 0;
- $App::DEBUG_FILE = "";
}
#################################################################
@[EMAIL PROTECTED]
-330,10 +329,26 @[EMAIL PROTECTED]
my $debug_file = $App::options{debug_file};
if ($debug_file) {
- if ($debug_file !~ /^[>|]/) {
- $debug_file = ">> $debug_file";
+ if ($debug_file eq "STDOUT") {
+ $App::DEBUG_FILE = \*STDOUT;
}
- open(App::DEBUG_FILE, $debug_file);
+ elsif ($debug_file eq "STDERR") {
+ $App::DEBUG_FILE = \*STDERR;
+ }
+ else {
+ if ($debug_file !~ /^[>|]/) {
+ $debug_file = "> $debug_file";
+ }
+ if (open(App::DEBUG_FILE_HANDLE, $debug_file)) {
+ $App::DEBUG_FILE = \*App::DEBUG_FILE_HANDLE;
+ }
+ else {
+ warn "WARNING: Couldn't open $debug_file: $!\n";
+ }
+ }
+ }
+ else {
+ $App::DEBUG_FILE = \*STDOUT;
}
}
@[EMAIL PROTECTED]
-864,19 +879,19 @[EMAIL PROTECTED]
if ($text_len + $trailer_len > $App::trace_width) {
my $len = $App::trace_width - $trailer_len;
$len = 1 if ($len < 1);
- print substr($text, 0, $len), $trailer, "\n";
+ print $App::DEBUG_FILE substr($text, 0, $len), $trailer,
"\n";
}
elsif ($App::trace_justify) {
my $len = $App::trace_width - $trailer_len - $text_len;
$len = 0 if ($len < 0); # should never happen
- print $text, ("." x $len), $trailer, "\n";
+ print $App::DEBUG_FILE $text, ("." x $len), $trailer,
"\n";
}
else {
- print $text, $trailer, "\n";
+ print $App::DEBUG_FILE $text, $trailer, "\n";
}
}
else {
- print $text, $trailer, "\n";
+ print $App::DEBUG_FILE $text, $trailer, "\n";
}
$calldepth++;
}
@[EMAIL PROTECTED]
-940,10 +955,10 @[EMAIL PROTECTED]
}
$text =~ s/\n/\\n/g;
if ($App::trace_width && length($text) > $App::trace_width) {
- print substr($text, 0, $App::trace_width), "\n";
+ print $App::DEBUG_FILE substr($text, 0, $App::trace_width),
"\n";
}
else {
- print $text, "\n";
+ print $App::DEBUG_FILE $text, "\n";
}
}
return(@[EMAIL PROTECTED]
);
Modified: p5ee/trunk/App-Context/lib/App/Context.pm
==============================================================================
--- p5ee/trunk/App-Context/lib/App/Context.pm (original)
+++ p5ee/trunk/App-Context/lib/App/Context.pm Fri Jun 22 14:00:38 2007
@[EMAIL PROTECTED]
-1766,8 +1766,8 @[EMAIL PROTECTED]
sub dbgprint {
my $self = ****ft;
- if (defined $App::options{debugfile}) {
- print App::DEBUGFILE $$, ": ", @[EMAIL PROTECTED]
"\n";
+ if (defined $App::options{debug_file}) {
+ print $App::DEBUG_FILE $$, ": ", @[EMAIL PROTECTED]
"\n";
}
else {
print STDERR "Debug: ", @[EMAIL PROTECTED]
"\n";


|