projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rearrange priv/lock tests independent of node type
[spider.git]
/
perl
/
DXDebug.pm
diff --git
a/perl/DXDebug.pm
b/perl/DXDebug.pm
index 28ae8fe56281137a056bac41954fa6013c1f8481..3ab7c77084693ec3ff41bbfae672a800fba90ddb 100644
(file)
--- a/
perl/DXDebug.pm
+++ b/
perl/DXDebug.pm
@@
-25,10
+25,11
@@
package DXDebug;
use 5.10.1;
package DXDebug;
use 5.10.1;
+use warnings;
require Exporter;
@ISA = qw(Exporter);
require Exporter;
@ISA = qw(Exporter);
-@EXPORT = qw(dbginit dbg dbgadd dbgsub dbglist dbgdump isdbg dbgclose dbgtrace confess croak cluck carp);
+@EXPORT = qw(dbginit dbg dbgadd dbgsub dbglist dbgdump isdbg dbgclose dbgtrace
dbgprintring dbgsetcat
confess croak cluck carp);
use strict;
use vars qw(%dbglevel $fp $callback $cleandays $keepdays $dbgringlth);
use strict;
use vars qw(%dbglevel $fp $callback $cleandays $keepdays $dbgringlth);
@@
-69,12
+70,12
@@
if (!defined $DB::VERSION) {
exit(-1);
}
sub carp {
exit(-1);
}
sub carp {
- DXDebug::dbgprintring(
25) if DXDebu
g('nologchan');
+ DXDebug::dbgprintring(
5) if DXDebug::isdb
g('nologchan');
# DXDebug::dbg(Carp::shortmess(\@_));
DXDebug::longmess(\@_);
}
sub cluck {
# DXDebug::dbg(Carp::shortmess(\@_));
DXDebug::longmess(\@_);
}
sub cluck {
- DXDebug::dbgprintring(
25) if DXDebu
g('nologchan');
+ DXDebug::dbgprintring(
5) if DXDebug::isdb
g('nologchan');
# DXDebug::dbg(Carp::longmess(\@_));
DXDebug::longmess(\@_);
} );
# DXDebug::dbg(Carp::longmess(\@_));
DXDebug::longmess(\@_);
} );
@@
-104,7
+105,7
@@
sub dbgtrace
last if $pkg =~ /Mojo/;
# say "*** in dbgtrace $i after mojo";
$_isdbg = 'trace';
last if $pkg =~ /Mojo/;
# say "*** in dbgtrace $i after mojo";
$_isdbg = 'trace';
- dbg("Stack ($i): $
pkg
::$subr in $fn line: $l");
+ dbg("Stack ($i): $
{pkg}
::$subr in $fn line: $l");
}
$_isdbg = '';
}
}
$_isdbg = '';
}
@@
-119,8
+120,8
@@
sub dbg
my @l = split /\n/, $r;
foreach my $l (@l) {
$l =~ s/([\x00-\x08\x0B-\x1f\x7f-\xff])/sprintf("%%%02X",ord($1))/eg;
my @l = split /\n/, $r;
foreach my $l (@l) {
$l =~ s/([\x00-\x08\x0B-\x1f\x7f-\xff])/sprintf("%%%02X",ord($1))/eg;
- print "$l\n" if defined \*STDOUT && !$no_stdout;
my $tag = $_isdbg ? "($_isdbg) " : '(*) ';
my $tag = $_isdbg ? "($_isdbg) " : '(*) ';
+ print "$tag$l\n" if defined \*STDOUT && !$no_stdout;
my $str = "$t^$tag$l";
&$callback($str) if $callback;
if ($dbgringlth) {
my $str = "$t^$tag$l";
&$callback($str) if $callback;
if ($dbgringlth) {
@@
-130,10
+131,12
@@
sub dbg
$fp->writeunix($t, $str) unless !$fp || $dbglevel{"nolog$_isdbg"} ;
}
}
$fp->writeunix($t, $str) unless !$fp || $dbglevel{"nolog$_isdbg"} ;
}
}
+ $_isdbg = '';
}
sub dbginit
{
}
sub dbginit
{
+ my $basename = shift || 'debug';
$callback = shift;
# add sig{__DIE__} handling
$callback = shift;
# add sig{__DIE__} handling
@@
-160,7
+163,7
@@
sub dbginit
}
}
}
}
- $fp = DXLog::new(
'debug'
, 'dat', 'd');
+ $fp = DXLog::new(
$basename
, 'dat', 'd');
dbgclearring();
}
dbgclearring();
}
@@
-182,6
+185,7
@@
sub dbgdump
my $l = shift;
my $m = shift;
if ($dbglevel{$l} || $l eq 'err') {
my $l = shift;
my $m = shift;
if ($dbglevel{$l} || $l eq 'err') {
+ my @out;
foreach my $l (@_) {
for (my $o = 0; $o < length $l; $o += 16) {
my $c = substr $l, $o, 16;
foreach my $l (@_) {
for (my $o = 0; $o < length $l; $o += 16) {
my $c = substr $l, $o, 16;
@@
-189,11
+193,12
@@
sub dbgdump
$c =~ s/[\x00-\x1f\x7f-\xff]/./g;
my $left = 16 - length $c;
$h .= ' ' x (2 * $left) if $left > 0;
$c =~ s/[\x00-\x1f\x7f-\xff]/./g;
my $left = 16 - length $c;
$h .= ' ' x (2 * $left) if $left > 0;
-
dbg($m . sprintf("%4d:", $o) . "$h $c")
;
+
push @out, $m . sprintf("%4d:", $o) . "$h $c"
;
$m = ' ' x (length $m);
}
}
$m = ' ' x (length $m);
}
}
- }
+ dbg(@out) if isdbg($l); # yes, I know, I have my reasons;
+ }
}
sub dbgadd
}
sub dbgadd
@@
-293,6
+298,12
@@
sub dbgclean
}
}
}
}
+# force a category for the next (unconditional) dbg message (replace (*) with (<something>))
+sub dbgsetcat
+{
+ $_isdbg = shift;
+}
+
1;
__END__
1;
__END__