From: Robert Klemme Date: 2010-10-14T02:50:13+09:00 Subject: Re: How to overwrite standard puts method On 10/13/2010 07:31 PM, Arkady Itkin wrote: > I'm pretty new to ruby. > I'm using buildR to build our software. > When buildR runs in the trace mode it prints out a huge amount of > information to the standard output which is difficult to understand. > > I would like to have a better control on the output format. > I thought about overwriting standard puts method and use log4R in the > new implementation to get better control on formatting/filtering. > > Can it be done? Any other idea on how to get the better control on > buildR output? There are several methods that write to stdout (off the top of my head at least puts, print, printf). One option would be to assign to $stdout another stream. If you want to catch child process output things get a bit more complicated. In that case you either need to use IO#popen to handle child process output or open a pipe and use $stdout.reopen to attach the write end of the pipe to the stream. You then need to read (asynchronously, i.e. in a thread) from the read end. Btw, why is offline filtering not an option? I mean, if you write stdout to a file you can filter whatever you like and you still have the whole output. Kind regards robert