Reputation: 853
We have a fairly large rails application and I have started this output in our unicorn.log:
#:0xc644248>#:0xc644248>#:0xc4f06e4>#:0xc4f06e4>#:0xca481b4>#:0xca481b4>#:0xc53f604>#:0xc53f604>#:0xcd7a60c>#:0xcd7a60c>#:0xc5df2f8>#:0xc5df2f8>#:0xc69fd00>#:0xc69fd00>#:0xc560ae8>#:0xc560ae8>
It seems to me like there probably is a stray Kernel.puts method call somewhere, but I've been searching for hours and can't find it.
Anyone have tips for tracking something like this down?
Upvotes: 3
Views: 263
Reputation: 81450
Have you checked for display
? That's another method that prints stuff out.
Upvotes: 2
Reputation: 978
This is what I use, it's similar to Banang's answer but maybe even simpler. Do a grep from the directory like so:
grep -rn 'puts' .
Sure it searches everything but you can run it in whatever directory you want to limit that. That should give you the file and line number you need. You can fine tune the search criteria as you wish.
Upvotes: 0
Reputation: 8204
You could go over all the files and search for any calls to Kernel.puts, like so:
find -iname "*.rb" | xargs grep -iR 'Kernel.puts'
However, in terms of neatness (and effectiveness), I would probably go for the solution provided by Jeff Paquette.
Upvotes: 1
Reputation: 7127
You could monkey patch puts, and raise an exception when it's called. You could even fine tune that with a regexp match on your output string (which looks like a recursive object dump).
module Kernel
def puts (s)
raise "puts called, check the backtrace for the source" if s =~ /#:[a-z0-9]>*/
end
end
It could also be that it's not a call to puts, but rather #inspect.
Upvotes: 9