From: Arkady Itkin Date: 2010-10-17T15:57:58+09:00 Subject: Re: How to overwrite standard puts method Robert, Thanks for the help. Please, see my comments inside. Arkady Robert Klemme wrote in post #950193: > On 14.10.2010 10:08, Arkady Itkin wrote: >>> >> 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). > > What kind of structure do you expect to get? As far as I can see > changing puts to internally delegate to a Logger can give you only > timestamp and maybe thread id because puts itself only accepts message > texts. You can especially *not* get log levels with this approach. > I was thinking about getting information on caller of the "puts" method. That will allow me to print out who invoked the "puts" method and even print it with indentation reflecting calling stack. >> 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. > > Yes, of course you can do that. But I still wonder what kind of > structure beyond added timestamps you expect. > >> 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. > > Whenever I need to debug an ant build I use option -d (debug, really > verbose), let all output flow into a file and look at it with my > favorite text editor [1]. That supports setting bookmarks based on > search patterns (POSIX regexp), you can copy all bookmarked lines into a > new document etc. Unfortunately buildR trace is not as useful as ant trace. For example, it does not print out the reason why it decides to trigger some task (at least I did not find it). Besides, contrary to ant, buildR is not pure declaration language but allows to write custom code which I want to debug. I wonder if I can use ruby debugger ti debug this code (meanwhile all my attempts failed, ruby debugger fails to load with builrR). Thanks, Arkady > > Cheers > > robert > > > [1] http://www.textpad.com/ -- Posted via http://www.ruby-forum.com/.