+{
+ return dbgtrace(@_);
+}
+
+sub dbgprintring
+{
+ return unless $fp;
+ my $i = shift || 0;
+ my $count = @dbgring;
+ $i = @dbgring-$i if $i;
+ return 0 unless $i < $count; # do nothing if there is nothing to print
+
+ my $first;
+ my $l;
+ 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 at line $i (zero base)");
+ $fp->writeunix($lt, "$lt^###");
+ $first = $t;
+ }
+ my $buf = sprintf "%02d:%02d:%02d", (gmtime($t))[2,1,0];
+ $fp->writeunix($lt, "$lt^RING: $buf^$str");
+ ++$l;
+ }
+ my $et = time;
+ $fp->writeunix($et, "$et^###");
+ $fp->writeunix($et, "$et^### RINGBUFFER END $l debug lines written");
+ $fp->writeunix($et, "$et^###");
+ return $l;
+}
+
+sub dbgclearring
+{
+ @dbgring = ();