customink / central_logger

Ruby Mongo DB Logger for Rails - centralized logging for rails apps in MongoDB. Converted to gem, added global exception logging, and added Rails 3 (or 2) support.
http://blog.philburrows.com/articles/2009/09/28/rails-logging-with-mongodb/
MIT License
128 stars 35 forks source link

Better handle when Benchmark is not set #1

Closed trevorturk closed 14 years ago

trevorturk commented 14 years ago

I haven't done too much testing of this, but I was having a problem where Devise (a Rails gem) was causing central_logger to fail when doing redirects (e.g. forcing a user to log in). I was getting an undefined method error because it was trying to call "0.real" -- so, I just made this create the correct kind of object in the case of failure. I'm not sure if this is the right solution, but I think something needs fixing, and this is my attempt. Thanks!

astupka commented 14 years ago

Thanks for debugging. I have other functional tests for exceptions in a test bed Rails app, but setting runtime = 0 worked for those cases, I'll have to figure out what's going on here. Do you have a stack trace you would be willing to send? In irb I get

>> 0.real
=> 0
trevorturk commented 14 years ago

Maybe there's a difference in version of Ruby? I'm not sure. I get this in irb:

ree-1.8.7-2010.02 > 0.real
NoMethodError: undefined method `real' for 0:Fixnum
from (irb):1
from :0
astupka commented 14 years ago

Ah, good call. You're right. I've only been testing with 1.9.2. I will switch in rvm and test your fix. Plenty of folks are probably using 1.8.7. Thank you.

Here: http://rdoc.info/docs/ruby-core/1.9.2/Numeric#real-instance_method Not here: http://rdoc.info/docs/ruby-core/1.8.7/Numeric

trevorturk commented 14 years ago

Cool - I'm reopening this pull request then. Please let me know if/when you fix in your repo -- I want to transition my apps off my fork. Thanks!

astupka commented 14 years ago

Trevor,

I made the fix vs accepting the pull request. I decided there was some code smell to me relying on the unrelated Numeric class and the Benchmark class having a real method in the insert_log_record method. Removing this also eliminated the need to pass in the result of a no-op Benchmark call.

https://github.com/customink/central_logger/commit/6dc230a55421176ae9ad7e73439b499ee0fafe14

Thanks for all your help. Alex

trevorturk commented 14 years ago

Awesome - thanks for fixing this!