require Exporter;
@ISA = qw(Exporter);
-@EXPORT = qw(dbginit dbg dbgadd dbgsub dbglist dbgdump isdbg dbgclose confess croak cluck);
+@EXPORT = qw(dbginit dbg dbgadd dbgsub dbglist dbgdump isdbg dbgclose confess croak cluck carp);
use strict;
use vars qw(%dbglevel $fp $callback $cleandays $keepdays $dbgringlth);
local $^W=0;
eval qq( sub confess {
\$SIG{__DIE__} = 'DEFAULT';
- DXDebug::dbgprintring() if DXDebug('nologchan');
+ DXDebug::dbgprintring() if DXDebug::isdbg('nologchan');
DXDebug::dbg(\$@);
DXDebug::dbg(Carp::shortmess(\@_));
exit(-1);
}
sub croak {
\$SIG{__DIE__} = 'DEFAULT';
- DXDebug::dbgprintring() if DXDebug('nologchan');
+ DXDebug::dbgprintring() if DXDebug::isdbg('nologchan');
DXDebug::dbg(\$@);
DXDebug::dbg(Carp::longmess(\@_));
exit(-1);
for (@l) {
s/([\x00-\x08\x0B-\x1f\x7f-\xff])/uc sprintf("%%%02x",ord($1))/eg;
print "$_\n" if defined \*STDOUT && !$no_stdout;
- my $str = "$t^$_";
+ my $tag = $_isdbg ? "($_isdbg) " : '';
+ my $str = "$t^$tag$_";
&$callback($str) if $callback;
if ($dbgringlth) {
shift @dbgring while (@dbgring > $dbgringlth);
sub dbgprintring
{
return unless $fp;
- my $count = shift || $dbgringlth+1;
+ my $count = shift;
my $first;
my $l;
- for ( ; $count > 0 && ($l = shift @dbgring); --$count) {
- my ($t, $str) = split /\^/, $l, 2;
+ my $i = defined $count ? @dbgring-$count : 0;
+ $count = @dbgring;
+ for ( ; $i < $count; ++$i) {
+ my ($t, $str) = split /\^/, $dbgring[$i], 2;
next unless $t;
my $lt = time;
unless ($first) {
$fp->writeunix($lt, "$lt^###");
- $fp->writeunix($lt, "$lt^### RINGBUFFER START");
+ $fp->writeunix($lt, "$lt^### RINGBUFFER START at line $i (zero base)");
$fp->writeunix($lt, "$lt^###");
$first = $t;
}