+sub isdbg($)
+{
+ return unless $fp;
+ if ($dbglevel{$_[0]}) {
+ $_isdbg = $_[0];
+ return 1;
+ }
+}
+
+sub shortmess
+{
+ return Carp::shortmess(@_);
+}
+
+sub longmess
+{
+ return Carp::longmess(@_);
+}
+
+sub dbgprintring
+{
+ return unless $fp;
+ my $count = shift;
+ my $first;
+ my $l;
+ 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 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");
+ }
+ my $et = time;
+ $fp->writeunix($et, "$et^###");
+ $fp->writeunix($et, "$et^### RINGBUFFER END");
+ $fp->writeunix($et, "$et^###");
+}
+
+sub dbgclearring
+{
+ @dbgring = ();
+}
+
+# clean out old debug files, stop when you get a gap of more than a month
+sub dbgclean