#389 - Add option to bypass Rails logger + update readme

This commit is contained in:
Steve Bazyl committed 2016-04-14 12:54:58 -07:00
1 parent e3d2a16a19
commit 4e19ae601f
3 files changed
+89 -2

No files matched your search

+12 -2
View File
@@ -39,10 +39,20 @@ module Google
logger
end
# Check to see if client is being used in a Rails environment and ge the logger if present
# Check to see if client is being used in a Rails environment and get the logger if present.
# Setting the ENV variable 'GOOGLE_API_USE_RAILS_LOGGER' to false will force the client
# to use its own logger.
#
# @return [Logger]
def self.rails_logger
::Rails.logger if defined?(::Rails) && ::Rails.respond_to?(:logger) && ::Rails.logger
if 'true' == ENV.fetch('GOOGLE_API_USE_RAILS_LOGGER', 'true') &&
defined?(::Rails) &&
::Rails.respond_to?(:logger) &&
!::Rails.logger.nil?
::Rails.logger
else
nil
end
end
end
end