update DWeather::Debug, Logger, Serial
[dweather.git] / DWeather / lib / DWeather / Debug.pm
index d67b70221022d02e129858c3622c2d417f9ba5d0..594d9372c0ee8d31911db1bf819409d2679dd686 100644 (file)
@@ -4,8 +4,6 @@
 #
 # Copyright (c) 1998 - Dirk Koopman G1TLH
 #
-# $Id: Debug.pm,v 1.1 2001/05/18 14:02:10 djk Exp $
-#
 # This library is free software; you can redistribute it and/or
 # modify it under the same terms as Perl itself.
 #
 package DWeather::Debug;
 
 require Exporter;
+
 @ISA = qw(Exporter);
 @EXPORT = qw(dbginit dbg dbgadd dbgsub dbglist dbgdump isdbg dbgclose confess croak cluck carp);
-$VERSION = sprintf( "%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/ );
+$VERSION = 1.23;
 
 use strict;
 use vars qw(%dbglevel $fp);
+use 5.01001;
 
-use DWeather::Logger;
+use SMGLog ();
 use Carp qw(cluck);
+use Time::HiRes qw(gettimeofday);
 
 %dbglevel = ();
 $fp = undef;
@@ -52,16 +53,18 @@ if (!defined $DB::VERSION) {
    );
 } 
 
+dbginit();
+
 sub dbg
 {
-       my $t = time
-       my $ts = sprintf("%02d:%02d:%02d", (gmtime($t))[2,1,0]);
+       my ($t,$ut) = gettimeofday
+       my $ts = sprintf "%02d:%02d:%02d:%03d", (gmtime($t))[2,1,0], $ut/1000;
        for (@_) {
                my $r = $_;
                chomp $r;
                my @l = split /\n/, $r;
                for (@l) {
-                       s/([\x00-\x1f\x7f-\xff])/uc sprintf("%%%02x",ord($1))/eg;
+                       s/([\x00-\x08\x0B-\x1f\x7f-\xff])/uc sprintf("%%%02x",ord($1))/eg;
 #                      print "$_\n" if defined \*STDOUT;
                        $fp->writeunix($t, "$ts $_"); 
                }
@@ -76,7 +79,7 @@ sub dbginit
                $SIG{__DIE__} = sub { dbg($@, Carp::longmess(@_)); };
        }
 
-       $fp = DWeather::Logger->new('debug', 'log', 'd') unless $fp;
+       $fp = SMGLog->new('debug', 'log', 'd');
 }
 
 sub dbgclose