0

I have some code (a Rails app) that generates output to console.

I'd like to use byebug to get the location of whatever is generating that output.

Is there a way to do that?

RalphShnelvar
  • 557
  • 1
  • 6
  • 17
  • Is the text printed by a method of which you know it's being called but don't know from where? – Linus Mar 05 '17 at 21:31
  • I'm not sure what you mean but ... I'd love to trap every 'puts', etc., that puts any text to stdout. – RalphShnelvar Mar 16 '17 at 23:41
  • Please have a look: https://github.com/deivid-rodriguez/byebug/blob/master/README.md#from-within-the-ruby-code – Linus Mar 17 '17 at 03:22

2 Answers2

0

Could you specify a little more? What do you mean by having "the location of whatever is generating that output"? Do you mean the trace? If yes, buybug has a backtrace (you can use where also) command. Have you look into this?

EDIT:

You could use pry with byebug (with the pry-byebug) and accomplish what you want.

Jeremie
  • 2,241
  • 2
  • 17
  • 25
0

Use pry gem for debugging code

Gemfile

gem 'pry'

add binding.pry anywhere to debug code

Community
  • 1
  • 1
puneet18
  • 4,341
  • 2
  • 21
  • 27