sub _write { my ($self, $message, $status) = @_; my $timestamp = (strftime "%d/%m/%Y %H:%M:%S", localtime); print STDOUT $timestamp, $self->{_separator}, $status, $self->{_separator}, $message, "\n"; $self; } # Constructor sub new { my $class = shift; ( bless {}, $class )->_init( {@_} ); } sub _init($) { my ($self, $args) = @_; $|=1; # Unbuffered output $self->{_rootdir} = $ENV{DIR_LOG}; # Set the rootdir for logfiles $self->{_separator} = $$args{separator} || ' - '; # Default one space - no concatenation is possible $self->_write("$0 started... (pid $$)", 'SYSTEM'); $self; } # Methods sub notify { my ($self, $message) = @_; my $status = 'NOTIFY'; $self->_write($message, $status); }