]> git.donarmstrong.com Git - debbugs.git/commitdiff
[project @ 2000-05-01 23:28:02 by doogie]
authordoogie <>
Tue, 2 May 2000 06:28:03 +0000 (22:28 -0800)
committerdoogie <>
Tue, 2 May 2000 06:28:03 +0000 (22:28 -0800)
The start of a .log parsing framework.  Very simple.

Debbugs/DBase.pm
Debbugs/DBase/Log.pm [new file with mode: 0644]
Debbugs/DBase/Log/Html.pm [new file with mode: 0644]
Debbugs/DBase/Log/Mail.pm [new file with mode: 0644]
Debbugs/DBase/Log/Message.pm [new file with mode: 0644]
Debbugs/DBase/LogEntry.pm [new file with mode: 0644]

index 6927faee53eb3d5b1ffcdda3d96533382d1dd2fa..67e97d3cc8cb3a9cbc9f7606fc2f178167723589 100644 (file)
@@ -26,6 +26,11 @@ use Fcntl ':flock';
 use Debbugs::Config;
 use Debbugs::Email;
 use Debbugs::Common;
+use Debbugs::DBase::Log;
+use Debbugs::DBase::Log::Html;
+use Debbugs::DBase::Log::Message;
+use Debbugs::DBase::Log::Mail;
+
 use FileHandle;
 use File::Basename qw(&dirname);
 use File::Path;
@@ -176,6 +181,17 @@ sub OpenLogfile
     }
 }
 
+sub ReadLogfile
+{
+    my $record = $_[0];
+    if ( $record eq $OpenedLog )
+    {
+       seek( $LogfileHandle, 0, 0 );
+       my $log = new Debbugs::DBase::Log;
+       $log->Load($LogfileHandle);
+    }
+}
+
 sub CloseLogfile
 {
     print "V: Closing log $OpenedLog\n" if $Globals{ 'verbose' };
diff --git a/Debbugs/DBase/Log.pm b/Debbugs/DBase/Log.pm
new file mode 100644 (file)
index 0000000..3e493b7
--- /dev/null
@@ -0,0 +1,75 @@
+# TODO: Implement 'stale' checks, so that there is no need to explicitly
+#      write out a record, before closing.
+
+package Debbugs::DBase::Log;
+
+use strict;
+                               
+sub new
+{
+    my $self  = {};
+#    $self->{LOG}    = new FileHandle;
+#    $self->{AGE}    = undef;
+#    $self->{PEERS}  = [];
+    $self->{log}       = [];
+    bless ($self);
+    return $self;
+}
+my %logClass = ();
+my %logType = ();
+sub Register
+{
+   my ($char, $type, $class) = (shift, shift, shift);
+   $logClass{ $char } = $class;
+   $logType{ $char } = $type;
+
+}
+
+sub Load
+{
+    my ($self, $handle) = (shift, shift);
+    foreach (keys %$self) {
+print "key=$_\n";
+}
+    while (<$handle>) {
+       chomp;
+       my ($char, $class, $type) = ($_, $logClass{ $_ }, $logType{ $_ });
+       my $msg = "";
+       while (<$handle>) {
+           chomp;
+           if ( $_ eq "\3" ) {
+               last;
+           } else {
+               $msg .= "$_\n";
+           }
+       }
+       if( defined($class) ) {
+           print "found handler $type for $char\n";
+           my $log = $class->new($msg);
+
+           my @log = $self->{log};
+           push @log, ($log);
+       } else {
+           print "undefined handler for $char\n";
+       }
+    }
+}
+
+BEGIN {
+        use Exporter   ();
+        use vars       qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+
+        # set the version for version checking
+        $VERSION     = 1.00;
+
+        @ISA         = qw(Exporter);
+        @EXPORT      = qw(new);
+        %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
+
+        # your exported package globals go here,
+        # as well as any optionally exported functions
+        @EXPORT_OK   = qw();
+
+}
+
+1;
diff --git a/Debbugs/DBase/Log/Html.pm b/Debbugs/DBase/Log/Html.pm
new file mode 100644 (file)
index 0000000..b0eca6b
--- /dev/null
@@ -0,0 +1,25 @@
+# TODO: Implement 'stale' checks, so that there is no need to explicitly
+#      write out a record, before closing.
+
+package Debbugs::DBase::Log::Html;
+
+use strict;
+
+BEGIN {
+       Debbugs::DBase::Log::Register("\6", "Html", "Debbugs::DBase::Log::Html");
+}
+
+
+sub new
+{
+    my $self  = {};
+    $self->{TYPE}      = "Html";
+    $self->{MSG}       = shift;
+    bless ($self);
+    return $self;
+}
+
+END { }       # module clean-up code here (global destructor)
+
+
+1;
diff --git a/Debbugs/DBase/Log/Mail.pm b/Debbugs/DBase/Log/Mail.pm
new file mode 100644 (file)
index 0000000..9d23c77
--- /dev/null
@@ -0,0 +1,30 @@
+# TODO: Implement 'stale' checks, so that there is no need to explicitly
+#      write out a record, before closing.
+
+package Debbugs::DBase::Log::Mail;
+use Debbugs::DBase::LogEntry;
+use Exporter;
+
+use strict;
+BEGIN {
+       use vars        qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+       @ISA = ( "Debbugs::DBase::LogEntry" );
+       Debbugs::DBase::Log::Register("\2", "Mail", "Debbugs::DBase::Log::Mail");
+}
+
+
+sub new
+{
+    my $proto = shift;
+    my $class = ref($proto) || $proto;
+    my $self  = {};
+    $self->{TYPE}      = "Html";
+    $self->{MSG}       = shift;
+    bless ($self, $class);
+    return $self;
+}
+
+END { }       # module clean-up code here (global destructor)
+
+
+1;
diff --git a/Debbugs/DBase/Log/Message.pm b/Debbugs/DBase/Log/Message.pm
new file mode 100644 (file)
index 0000000..ceebb12
--- /dev/null
@@ -0,0 +1,25 @@
+# TODO: Implement 'stale' checks, so that there is no need to explicitly
+#      write out a record, before closing.
+
+package Debbugs::DBase::Log::Message;
+
+use strict;
+
+BEGIN {
+       Debbugs::DBase::Log::Register("\7", "Message", "Debbugs::DBase::Log::Message");
+}
+
+
+sub new
+{
+    my $self  = {};
+    $self->{TYPE}      = "Message";
+    $self->{MSG}       = shift;
+    bless ($self);
+    return $self;
+}
+
+END { }       # module clean-up code here (global destructor)
+
+
+1;
diff --git a/Debbugs/DBase/LogEntry.pm b/Debbugs/DBase/LogEntry.pm
new file mode 100644 (file)
index 0000000..c9ec852
--- /dev/null
@@ -0,0 +1,69 @@
+# TODO: Implement 'stale' checks, so that there is no need to explicitly
+#      write out a record, before closing.
+
+package Debbugs::DBase::LogEntry;
+
+use strict;
+                               
+sub new
+{
+    my $self  = {};
+#    $self->{LOG}    = new FileHandle;
+#    $self->{AGE}    = undef;
+#    $self->{PEERS}  = [];
+    $self->{log}       = [];
+    $self->{Load}      = &Load;
+    bless ($self);
+    return $self;
+}
+my %logClass = ();
+my %logType = ();
+
+sub Load
+{
+    my ($self, $handle) = (shift, shift);
+    foreach (keys %$self) {
+print "key=$_\n";
+}
+    while (<$handle>) {
+       chomp;
+       my ($char, $class, $type) = ($_, $logClass{ $_ }, $logType{ $_ });
+       my $msg = "";
+       while (<$handle>) {
+           chomp;
+           if ( $_ eq "\3" ) {
+               last;
+           } else {
+               $msg .= "$_\n";
+           }
+       }
+       if( defined($class) ) {
+           print "found handler $type for $char\n";
+           my $log = $class->new($msg);
+
+           my @log = $self->{log};
+           push @log, ($log);
+       } else {
+           print "undefined handler for $char\n";
+       }
+    }
+}
+
+BEGIN {
+        use Exporter   ();
+        use vars       qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+
+        # set the version for version checking
+        $VERSION     = 1.00;
+
+        @ISA         = qw(Exporter);
+        @EXPORT      = qw(new);
+        %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
+
+        # your exported package globals go here,
+        # as well as any optionally exported functions
+        @EXPORT_OK   = qw();
+
+}
+
+1;