Richard Ryan email@example.com wrote in message news:firstname.lastname@example.org…
Thanks for the suggestion. The problem with metaphor is that the
intended idea can be too easily miscommunicated. By ``symphony’'
I was referring to the complexity of the code structure.
If by complexity you mean not calling the same function 6 times with
different args, then by all means continue using your prefered tool:
exec 1> /tmp/logfile.out 2>&1
… do stuff
Anyway, that being said, if you put the merging of stdout together
with stderr into the logfile which is in my second example, you’ll
probably get back at least the same number of lines, and you’ll still
have the complexity (if not quite a bit more).
True, the simplist ruby example:
err = $stderr
out = $stdout
open( “logfile.text”, “a” ) do |file|
$stdout = $stderr = file
# … do stuff
$stderr = err
$stdout = out
However, if this is a common operation for you, Ruby allows you to
improve on the above by abstracting the functionality and letting you
pull it in. That’s what the require ‘redirect’ solution is about.
Also, please keep in
mind that I am thinking of putting a significant amount of code inside
of the redirection and merging—I would definitely like to avoid the
extra block if at all possible.
Which block is extra, and what is wrong with it?
Also, please note that in my second
example I ``un-merge’’ stdout from stderr when I’m done.
so have all the examples