From: Arkady Itkin Date: 2010-10-14T17:08:39+09:00 Subject: Re: How to overwrite standard puts method Robert Klemme wrote in post #949915: > On 10/13/2010 07:31 PM, Arkady Itkin wrote: >> 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. > It looks like I did not explain my problem correctly. I'm trying to debug a huge amount of buildR code which overflows me with tons of information printed out. Of course, I can redirect it to the file (both from within the code or from command prompt) and then try to filter out the needed information from the saved output. But since the output it's not well organized/structured it's not an easy task. I thought about replacing all puts/print etc. calls that exists in the code by log4R which can be controlled from outside (and, on the way provide better structured output). Of course, I can find and replace puts/sprints etc. in the code to my method. But this is huge amount of code and I'm lazy :-). So, I thought about some trick which will allow me to overwrite standard output methods like puts and get control of the output into my code where I can do whatever I want. It may be useful for other people as well when they need to debug the build code. BTW, any other idea on how to debug buildR code will be appreciated. I tried to use ruby debugger with it but it fails in attempt to load buildR stuff. Thanks in advance, Arkady -- Posted via http://www.ruby-forum.com/.