davejacobs / letters

A tiny debugging library for Ruby
Other
271 stars 9 forks source link

Add support for printing current file+line #8

Closed suan closed 11 years ago

suan commented 12 years ago

I wrote quick-debug not too long ago, but then I came across letters and I love it.

One thing I don't think you have though and which I think would be really useful, is a way to print just the current file+line (without an entire stacktrace). It is very useful for giving context. For example in quick-debug, If you do D.bg(:in){'someobj'} it would print out something like [/path/to/code/file:99] someobj ~> <someobj.inspect>

Apart from that, hopefully you wouldn't mind skimming through quick-debug - there might be some other ideas there that you might like. For example another thing I hope you'd consider adding is having an option to use a dedicated log file regardless of where I call Letter's log methods from. In quick-debug I write them all to /tmp/quick-debug.txt, and within large projects it's been tremendously useful to see only the debug statements I care about all in a single file.

davejacobs commented 12 years ago

I like these suggestions. I'll look into the over the weekend.

davejacobs commented 12 years ago

Do you envision having the file line printed out every time a letters method is called? Or only if it goes to STDOUT? I'm trying to keep letters methods as orthogonal as possible. What about a :line_no option that you can pass into any letters method that has output?

(I'm going to push a Letters config block in the next day or so, so you could turn it on by default.)

muescha commented 12 years ago

i think it would be nice to have it as global parameter so that i can decide at only one time i need this info (and not nedd to include it in every call)

maybe somehow like #11 you do require 'letters/log_file_and_line'

or it can be done in the way to make it with :line_no option and create a way setup default options values which i can set at the begin of file (for all options :line_no or for letter+option like :d_line_no ). this is more global and other options benefit from this.

suan commented 12 years ago

Sorry for the late response!

Ideally what I'd like to see is the file line printed out next to anything from letters printed out to STDOUT or to a log file. It can either be on or off by default, and can be configured somewhere other than after the gem is loaded, (for example, a ~/.lettersrc config file) The reason being that letters is a library that is usually manually typed in and required at debug time, and it's tedious to have to "turn on" this feature everytime I add it into my code.

davejacobs commented 11 years ago

Okay, sorry for the massive delay. I've been in Clojure land recently. I have more time to add features to Letters now, though, so I want to clarify -- do you want the line number of any Letters call logged to STDOUT when that method is called?

davejacobs commented 11 years ago

This is supported now! To see it in action:

require "letters"

Letters.config do
  all :line_no => true
end

[1, 2, 3].b.map {|x| x ** 2 }.a { size == 3 }.select(&:odd?)