pauldowman / better_logging

(Old/dead) A Rails plugin that improves the log format.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Runtime error on Ruby 2, Rails 4

kreeger opened this issue · comments

A bit ahead of the curve, perhaps, but I'm getting an error at runtime when I boot up a Rails 4 (beta1) server; evidently ActiveSupport::BufferedLogger is no more.

/Users/bkreeger/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/better_logging-1.0.3/lib/better_logging/better_logging.rb:12:in `<module:BetterLogging>': uninitialized constant ActiveSupport::BufferedLogger (NameError)
    from /Users/bkreeger/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/better_logging-1.0.3/lib/better_logging/better_logging.rb:10:in `<module:RailsPlugins>'
    from /Users/bkreeger/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/better_logging-1.0.3/lib/better_logging/better_logging.rb:9:in `<module:PaulDowman>'
    from /Users/bkreeger/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/better_logging-1.0.3/lib/better_logging/better_logging.rb:8:in `<top (required)>'
    from /Users/bkreeger/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/better_logging-1.0.3/lib/better_logging.rb:2:in `require'
    from /Users/bkreeger/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/better_logging-1.0.3/lib/better_logging.rb:2:in `<top (required)>'
    from /Users/bkreeger/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0/lib/bundler/runtime.rb:72:in `require'
    from /Users/bkreeger/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
    from /Users/bkreeger/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0/lib/bundler/runtime.rb:70:in `each'
    from /Users/bkreeger/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0/lib/bundler/runtime.rb:70:in `block in require'
    from /Users/bkreeger/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0/lib/bundler/runtime.rb:59:in `each'
    from /Users/bkreeger/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0/lib/bundler/runtime.rb:59:in `require'
    from /Users/bkreeger/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0/lib/bundler.rb:132:in `require'
    from /Users/bkreeger/Code/universal-uclick/support/otterloop/config/application.rb:10:in `<top (required)>'
    from /Users/bkreeger/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/railties-4.0.0.beta1/lib/rails/commands.rb:76:in `require'
    from /Users/bkreeger/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/railties-4.0.0.beta1/lib/rails/commands.rb:76:in `block in <top (required)>'
    from /Users/bkreeger/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/railties-4.0.0.beta1/lib/rails/commands.rb:73:in `tap'
    from /Users/bkreeger/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/railties-4.0.0.beta1/lib/rails/commands.rb:73:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

If/when I have time, I may submit a pull request to see if I can fix this, unless someone else beats me to it.

Thanks for pointing it out! A pull request would be awesome, otherwise I'll try to get to it when I can but I haven't had much time to play with Rails 4 yet.

http://edgeguides.rubyonrails.org/4_0_release_notes.html#active-support-deprecations

BufferedLogger is deprecated. Use ActiveSupport::Logger, or the logger from Ruby stdlib.

I simply replaced all ActiveSupport::BufferedLogger with ActiveSupport::Logger. Because I haven't had time to do the "if..else.." work yet. This solution results in a version that may break rails 3.x. So I simply use

gem 'better_logging', github: 'snow/better_logging'

in rails4 projects and origin gem in rails3 projects.

And this folk is only intend for temporary use till the origin gem release a version that supports rails 4.

sorry for my broken Englisth.

Thanks, I'll try to find the time to do it in a conditional way.

and, in lib/better_logging/better_logging.rb, ln 32, should use Rails::VERSION::MAJOR instead of Rails.version.to_i, because Rails.version maybe '4.0.0.beta1'

snow@ac2a741

Thanks!

Update for Rails 4 coming as soon as I have time.

Actually, when I switch to this other fork (on rails 4), the output is now empty, like this:

=> Booting Thin
=> Rails 4.1.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
Thin web server (v1.6.3 codename Protein Powder)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop
DEBUG
DEBUG
INFO
INFO
INFO
DEBUG
DEBUG
INFO
INFO
INFO
INFO

Sorry, I'm not maintaining (or even using) this any more, but check @foodforarabbit's fork:

https://github.com/foodforarabbit/better_logging/