Hey guys,
Thanks for all the input! I learned a few new things from your suggestions.
The Log4perl package looks promising if we ever do a redesign of our system, but it is too much of a code change (would be several thousand lines).
I continue to not be able to use tee beyond one create/kill cycle, after that I get an argument error from tee: tee: write error: Invalid argument perhaps there is an issue with my tee? Where are you guys executing tee from?
I was able to get it to work using a combination of tie, local, and opening the logfile prior to doing it in the tie class. So the code below is working with the InstallerHandleTie I have shown in another reply:
use InstallerHandleTie;
select STDERR; $| = 1; # make unbuffered
select STDOUT; $| = 1; # make unbuffered
my $gfh = *STDOUT;
my $geh = *STDERR;
for (1, 2) {
local *STDOUT;
local *STDERR;
my $outfile = "globlog_$_.txt";
open LOGFILE, ">$outfile";
tie *STDOUT, 'InstallerHandleTie', *LOGFILE, $gfh;
tie *STDERR, 'InstallerHandleTie', *LOGFILE, $geh;
print "STDOUT in $outfile\n";
warn "STDERR in $outfile\n";
untie *STDOUT;
untie *STDERR;
close LOGFILE;
}
print "outside of tie loop, I should not be in a log file\n";
warn "outside warning - not in log\n";
Thanks! Rick |