package TextLogger; use strict; use warnings; use Helpers; sub new { my ($class, %config) = @_; my $self = bless \%config, $class; $self->log("Logfile for " . $self->{appname} . " (re)started"); return $self; } sub log { my ($self, $logline) = @_; my $fullline = Helpers::getISODate() . " $logline\n"; open($self->{fh}, ">>", $self->{logfile}); print {$self->{fh}} $fullline; close($self->{fh}); print $fullline . "\n"; } sub alive { my ($self) = @_; $self->log("-- " . $self->{appname} . " is alive --"); } sub DESTROY { my ($self) = @_; $self->log("Stopping logfile"); } 1;