The stupid question is the question not asked | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
OK, I realize Log4Perl is a lot of work rewriting your scripts, but trust me, it's worth it. For a quick start, follow the easy_init directions, and just replace all your 'print "' with $log->info(), and all the warn or 'print STDERR' calls with $log->warn().
But, of course you would like to use as much of the existing script as possible. So, to address your current problem, try using \*STDOUT directly in the IO::Tee call. I've found odd behavior when I pass it as another variable, vs passing it as \*STDOUT and \*STDERR. Call multiplex with some sort of indicator instead of the reference (a string perhaps "STDOUT" or "STDERR"), and make separate calls to IO::Tee for each of these. To debug this, try using the handles method of IO::Tee. Add a print join(' ', $tee->handles), "\n"; (taken from the perldocs) to your multiplex method to see what it's really producing. Compare the results of using the Handle reference, vs using \*STDOUT. I know the above works, but making separate calls to IO::Tee is pretty ugly. This is untested, but you might try creating a new filehandle object pointing to STDOUT. Perhaps something like IO::File->new(\*STDOUT), or more basic, IO::Handle->new_from_fd(fileno(STDOUT),"w"). Pass the return value from one of these to multiplex instead of the reference to the glob. ~J In reply to Re: Re: Multiplexing STDOUT and STDERR
by jmanning2k
|
|