Output Logging Routine
Date : April 16, 2003
This code will allow logging into a file and optionally, to the screen as well. This will create the file if necessary.
sub mlog { my ($msg) = @_; open (FH, ">> /tmp/logfile.log") or croak "error opening logfile: $!n"; my $timestamp = localtime; print FH "$timestamp: $msgn"; close FH; print "$timestamp: $msgn"; # also log to the screen }
And to use this in your code:
mlog("This is a test log");
Tags:
Perl