isotope has asked for the wisdom of the Perl Monks concerning the following question:
sub open_logfile { my $filename = shift; # Our filehandle reference object local *FH; # Attempt to open the file if(open(FH, "> " . $filename)) { # Opened the file print $FH_STATUS "Opened logfile: " . $filename . "\n"; select(FH); $| = 1; # Unbuffer select(STDOUT); # Restore default print to STDOUT return *FH; # Return the new fh reference } else { # Couldn't open the file... print $FH_ERROR "Problem opening logfile: \n"; print $FH_ERROR $filename . ":\n"; print $FH_ERROR $! . "\n"; print $FH_ERROR "Redirecting logging to Error log\n\n"; sleep 5; return $FH_ERROR; } }
use IO::Tee; $FH_STATUS = new IO::Tee(\*STDOUT, new_logfile(name_logfile('logs/QTStatus')));
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Teeing STDOUT and STDERR to files using filehandle references
by isotope (Deacon) on Dec 16, 2000 at 04:03 UTC | |
Re: Teeing STDOUT and STDERR to files using filehandle references
by isotope (Deacon) on Dec 16, 2000 at 01:03 UTC | |
by repson (Chaplain) on Dec 16, 2000 at 07:30 UTC | |
by isotope (Deacon) on Dec 18, 2000 at 22:11 UTC | |
by cwest (Friar) on Dec 16, 2000 at 01:22 UTC |