1 package The00z
::Logger
;
6 our $VERSION = '0.0.1';
11 my ($pkg,$logfile) = @_;
15 my $filehandler = IO
::File
->new(">>$logfile")
16 or croak
"Cannot open $logfile\n";
18 $self->{'filehandler'} = $filehandler;
20 $self->{'logfile'} = $logfile;
22 $self->{'filehandler'}->print("Opening "
23 . $self->{'logfile'} . " : " . localtime(time) . "\n");
33 my ($self, $level) = (shift, shift);
35 if ($level <= $self->{'level'})
37 $self->{'filehandler'}->print($_) for @_;
44 my ($self, $level) = @_;
45 $self->{'level'} = $level
46 if @_ == 2 and $level =~ m/^\d+$/;
47 return $self->{'level'};
55 $self->write($self->{'level'} ,"Closing ". $self->{'logfile'} . " : "
56 . localtime(time) . "\n");
58 $self->{'filehandler'}->close()
59 or croak
"Unable to write " . $self->{'logfile'} . "\n";