51edb33b5153edd7420443e044c36b8276bdbcf6
[arvados.git] / lib / google / api_client / railtie.rb
1 require 'rails/railtie'
2 require 'google/api_client/logging'
3
4 module Google
5   class APIClient
6     
7     ##
8     # Optional support class for Rails. Currently replaces the built-in logger
9     # with Rails' application log.
10     #
11     class Railtie < Rails::Railtie
12       initializer 'google-api-client' do |app|
13         _logger = case
14                     when app.respond_to?(:logger)        then app.logger
15                     when app.config.respond_to?(:logger) then app.config.logger
16                     else                                      Rails.logger
17                   end
18                   
19         Google::APIClient.logger = _logger
20       end
21     end
22   end
23 end