Hey,
I don't have the answer but I think it can be done by overriding the
conf settings.

Open up IRB and type conf
 I am on a mac and I see
conf.io=#<IRB::ReadlineInputMethod:0x3b63c>
conf.irb=#<IRB::Irb:0x41758>
conf.irb_name="irb"
conf.irb_path="(irb)"
conf.last_value=...
conf.line_no=12
conf.load_modules=[]
conf.output_method=#<IRB::StdioOutputMethod:0x1c96c>

The StdioOutputMethod rdoc only shows a print method
http://www.ruby-doc.org/core/classes/IRB/StdioOutputMethod.html
And all the code does is pass the args to STDOUT.print. If your log
class has a print method try setting your conf.output_method to an
instance of it.

The ReadLineInput is the same but with more methods.
http://www.ruby-doc.org/core/classes/IRB/ReadlineInputMethod.html
Once you figure this part out you can drop it in your irbrc file it
will load every time you start up irb.

Thanks
Becker

---------- Forwarded message ----------
From: Shin guey Wong <sgwong513 / hotmail.com>
Date: Dec 12, 2007 9:58 AM
Subject: Logging irb stdin & stdout to file but still remain showin
To: ruby-talk ML <ruby-talk / ruby-lang.org>


Hi,

I search the ruby-talk and find a few discussion on redirecting the
STDIN, STDOUT and STDERR. However, I still couldn't get it to work on
redirecting the IO to file and also to the console. I am working on
windows.

Here is what I want to do,
1. run irb,
2. run a command like :
   log "c:\irb_log.txt"
3. continue on irb and run other command, all the stdin, stdout and
stderr will be logging into the irb_log.txt and still showing on screen.
4. run nolog,    :it will stop loggin the stdin, stdout and stderr.

Anyone has any idea how to do this?
I have try to redirect the output like STDOUT.repopen("c:\tmp.log",
"w"), but i will not get the output on the console.

Thanks in advance.
--
Posted via http://www.ruby-forum.com/.