Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: Porting Perl 5.6 to Perl 5.8 issue with self-tie

by TedYoung (Deacon)
on Dec 12, 2006 at 01:55 UTC ( [id://589206]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Porting Perl 5.6 to Perl 5.8 issue with self-tie
in thread Porting Perl 5.6 to Perl 5.8 issue with self-tie

Yea, even if you can get them out to the same file, it would probably be safer to use Log::Log4perl. Any, you will get a richer logging featureset.

Ted Young

($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)

Replies are listed 'Best First'.
Re^4: Porting Perl 5.6 to Perl 5.8 issue with self-tie
by fwashbur (Sexton) on Dec 12, 2006 at 17:13 UTC
    Thanks Ted,

    Looks like we missed the boat on Log4perl. That would have been a great logging facility. Unfortunately we already have a few million lines of Perl embedded with print/printf which I need to try to get working on 5.8 without major coding changes.

Re^4: Porting Perl 5.6 to Perl 5.8 issue with self-tie
by fwashbur (Sexton) on Dec 12, 2006 at 22:37 UTC
    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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://589206]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (1)
As of 2024-04-19 18:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found