]> git.donarmstrong.com Git - debbugs.git/blob - Debbugs/DBase/Log.pm
pass uri_escape to templates in bugreport.cgi
[debbugs.git] / Debbugs / DBase / Log.pm
1 # TODO: Implement 'stale' checks, so that there is no need to explicitly
2 #       write out a record, before closing.
3
4 package Debbugs::DBase::Log;
5
6 use strict;
7                                 
8 sub new
9 {
10     my $self  = {};
11 #    $self->{LOG}    = new FileHandle;
12 #    $self->{AGE}    = undef;
13 #    $self->{PEERS}  = [];
14     $self->{log}        = [];
15     bless ($self);
16     return $self;
17 }
18 my %logClass = ();
19 my %logType = ();
20 sub Register
21 {
22    my ($char, $type, $class) = (shift, shift, shift);
23    $logClass{ $char } = $class;
24    $logType{ $char } = $type;
25
26 }
27
28 sub Load
29 {
30     my ($self, $handle) = (shift, shift);
31     foreach (keys %$self) {
32 print "key=$_\n";
33 }
34     while (<$handle>) {
35         chomp;
36         my ($char, $class, $type) = ($_, $logClass{ $_ }, $logType{ $_ });
37         my $msg = "";
38         while (<$handle>) {
39             chomp;
40             if ( $_ eq "\3" ) {
41                 last;
42             } else {
43                 $msg .= "$_\n";
44             }
45         }
46         if( defined($class) ) {
47             print "found handler $type for $char\n";
48             my $log = $class->new($msg);
49
50             my @log = $self->{log};
51             push @log, ($log);
52         } else {
53             print "undefined handler for $char\n";
54         }
55     }
56 }
57
58 BEGIN {
59         use Exporter   ();
60         use vars       qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
61
62         # set the version for version checking
63         $VERSION     = 1.00;
64
65         @ISA         = qw(Exporter);
66         @EXPORT      = qw(new);
67         %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
68
69         # your exported package globals go here,
70         # as well as any optionally exported functions
71         @EXPORT_OK   = qw();
72
73 }
74
75 1;