j.goor has asked for the wisdom of the Perl Monks concerning the following question:
sub _write { my ($self, $message, $status) = @_; my $timestamp = (strftime "%d/%m/%Y %H:%M:%S", localtime); print STDOUT $timestamp, $self->{_separator}, $status, $self->{_sep +arator}, $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 spa +ce - no concatenation is possible $self->_write("$0 started... (pid $$)", 'SYSTEM'); $self; } # Methods sub notify { my ($self, $message) = @_; my $status = 'NOTIFY'; $self->_write($message, $status); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Passing filehandles
by gellyfish (Monsignor) on Jan 10, 2005 at 13:51 UTC | |
|
Re: Passing filehandles
by gaal (Parson) on Jan 10, 2005 at 13:53 UTC |