File-SmartTail
view release on metacpan or search on metacpan
lib/File/SmartTail/DB.pm view on Meta::CPAN
STATUS => \%STATUS,
STATFILE => $STATFILE,
STATUSKEY => $statuskey,
TIETYPE => $tietype,
}, ref $type || $type;
#
# keep our own reference, so the logging object is
# destroyed AFTER $self.
#
$self->{LOG} = LOG();
$self->sync;
return $cache{$cachekey} = $self;
}
}
sub sync {
my $self = shift;
if ($self->{STATFILE} && $self->can('sync')) {
eval {
$self->{STATFILE}->sync
};
}
}
sub DESTROY {
my $self = shift or return;
$self->sync;
# LOG()->debug( sub {
# my $tt = $self->{TIETYPE} || '';
# my $sf = $self->{STATFILE} || '';
# my $ds = $self->DumpStatus || '';
# "sub DESTROY: TIETYPE: $tt; STATFILE: $sf; $ds";
# } );
# delete $self->{STATFILE}; # undef necessary?
# untie %{ $self->{STATUS} }; # will this do the right thing?
}
sub DumpStatus {
my $self = shift or return;
my %h = @_;
my $indent = $h{indent};
defined $indent or $indent = 1;
my $tab = "\t" x $indent;
my $sk = $self->{STATUSKEY} || '';
my @k = $self->{STATUS} ? sort keys %{ $self->{STATUS} } : ();
my @m = @k ? map "$_ =>\t$self->{STATUS}->{$_}", @k : ();
return join "\n$tab", "STATUSKEY file: $sk:", @m;
}
{
my $v;
sub LOG {
$v ||= require File::SmartTail::Logger && File::SmartTail::Logger::LOG();
}
}
1;
( run in 2.494 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )