jordansissel / ruby-cabin

Structured+contextual logging experiments in Ruby
Other
153 stars 22 forks source link

Parsing backtrace doesn't work in ruby 1.8.7 #14

Closed dkowis closed 11 years ago

dkowis commented 11 years ago

So if you do, you get a nasty exception:

undefined method `[]' for nil:NilClass
/home/dkowis/.rvm/gems/ruby-1.8.7-p371/gems/cabin-0.6.0/lib/cabin/mixins/logger.rb:112:in `debugharder'
/home/dkowis/.rvm/gems/ruby-1.8.7-p371/gems/cabin-0.6.0/lib/cabin/mixins/logger.rb:100:in `_log'
/home/dkowis/.rvm/gems/ruby-1.8.7-p371/gems/cabin-0.6.0/lib/cabin/mixins/logger.rb:79:in `log_with_level'
/home/dkowis/.rvm/gems/ruby-1.8.7-p371/gems/cabin-0.6.0/lib/cabin/mixins/logger.rb:64:in `debug'
./lib/tasks/packaging.rake:87

Diagnosing with puts'es from a project of mine: This stems from the BACKTRACE_RE:

BACKTRACE_RE: (?-mix:([^:]+):([0-9]+):in(.*)')`

The callinfo variable when used in a rake task is:

CALLINFO: ./lib/tasks/packaging.rake:87

So yeah, that regexp doesn't match, and then it's all over :(

dkowis commented 11 years ago

A workaround for me was to put it into a class, and now I get epic butt-tons of debug information :D

jordansissel commented 11 years ago

This works fine for me: https://gist.github.com/jordansissel/5806284

dkowis commented 11 years ago

Darn, stupid old ruby. I'll just keep using my class hack for now then.

Thanks :)

jordansissel commented 11 years ago

The problem is ruby 1.8's format for backtraces is different, it seems, than 1.9's.

Yay ruby :(

jordansissel commented 11 years ago

fixed by dca5cb7c5a6c5d70eac02baa8ed8d0607e605c26

jordansissel commented 11 years ago

cabin 0.6.1 released.

dkowis commented 11 years ago

Thanks for supporting old rubies, and sorry that I'm still on old rubies