Set app logger
authorNéstor Coppi <nestorcoppi@gmail.com>
Thu, 18 Dec 2014 14:07:17 +0000 (11:07 -0300)
committerNéstor Coppi <nestorcoppi@gmail.com>
Thu, 18 Dec 2014 14:07:17 +0000 (11:07 -0300)
For issue #183 I have the same problem with Rails 4.1.6 and Ruby 2.1 with that, we have covered some cases ^^

lib/google/api_client/railtie.rb

index d02e63456416470eddeac979613ffe6848bcdfa7..51edb33b5153edd7420443e044c36b8276bdbcf6 100644 (file)
@@ -10,7 +10,13 @@ module Google
     #
     class Railtie < Rails::Railtie
       initializer 'google-api-client' do |app|
-        Google::APIClient.logger = app.logger
+        _logger = case
+                    when app.respond_to?(:logger)        then app.logger
+                    when app.config.respond_to?(:logger) then app.config.logger
+                    else                                      Rails.logger
+                  end
+                  
+        Google::APIClient.logger = _logger
       end
     end
   end