rmosolgo / react-rails-hot-loader

Live-reload React.js components with Ruby on Rails & react-rails
MIT License
88 stars 24 forks source link

NoMethodError: undefined method `flush' for Logger #1

Open ilyadoroshin opened 9 years ago

ilyadoroshin commented 9 years ago

Hello, guys!

First of all, wanted to say thanks for that gem, works great! But I've found an issue: React::Rails::HotLoader.log: No flush method for Rails.logger in edge rails

For some reason, you decided to render all errors through your own method, which ends up running ::Rails.logger.flush, that is not available (at least in rails 4.1.6)

ilyadoroshin commented 9 years ago

FYI, this helped me to fix my problem.

// config/initializers/react_rails_hot_loader.rb
if Rails.env.development?
  React::Rails::HotLoader.class_eval do
    def self.log(message)
      msg = "[HotLoader] #{message}"
      ::Rails.logger.info(msg)
      ::Rails.logger.try(:flush)
    end
  end

  React::Rails::HotLoader.start()
end
rmosolgo commented 9 years ago

Thanks for the heads up!

Yeah, I used my own logger so I could modify all messages in one place, turn them off and on, etc.

Thanks for sharing your fix, I'll take a look at the changes in edge Rails and see what's a good long term solution

ilyadoroshin commented 9 years ago

@rmosolgo :+1: