2019-02-21 22:30:49 +03:00
|
|
|
package Log::Mini::LoggerFILE;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use IO::Handle;
|
|
|
|
|
2019-03-19 14:57:41 +03:00
|
|
|
|
2019-02-21 22:30:49 +03:00
|
|
|
use base 'Log::Mini::LoggerBase';
|
|
|
|
|
|
|
|
sub new {
|
|
|
|
my $self = shift->SUPER::new(@_);
|
|
|
|
my (%params) = @_;
|
|
|
|
|
|
|
|
$self->{file} = $params{file};
|
|
|
|
|
|
|
|
open my $fh, '>>', $params{file} or die $!;
|
|
|
|
if (defined $params{'synced'}) {
|
2019-03-19 14:57:41 +03:00
|
|
|
$fh->autoflush(1);
|
2019-02-21 22:30:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
$self->{fh} = $fh;
|
|
|
|
|
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub _print {
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
my $fh = $self->{fh};
|
2019-03-19 14:57:41 +03:00
|
|
|
print $fh @_;
|
2019-02-21 22:30:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub DESTROY {
|
|
|
|
close shift->{'fh'};
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
1;
|