lib/wcc/contentful.rb in wcc-contentful-1.2.1 vs lib/wcc/contentful.rb in wcc-contentful-1.3.0
- old
+ new
@@ -44,13 +44,12 @@
def locales
@locales ||= { 'en-US' => {} }.freeze
end
def logger
- return Rails.logger if defined?(Rails)
-
- @logger ||= Logger.new($stderr)
+ ActiveSupport::Deprecation.warn('Use WCC::Contentful::Services.instance.logger instead')
+ WCC::Contentful::Services.instance.logger
end
end
# Configures the WCC::Contentful gem to talk to a Contentful space.
# This must be called first in your initializer, before #init! or accessing the
@@ -88,19 +87,19 @@
downloader = WCC::Contentful::DownloadsSchema.new
downloader.update! if configuration.update_schema_file == :always || downloader.needs_update?
rescue WCC::Contentful::SimpleClient::ApiError => e
raise InitializationError, e if configuration.update_schema_file == :always
- WCC::Contentful.logger.warn("Unable to download schema from management API - #{e.message}")
+ Services.instance.logger.warn("Unable to download schema from management API - #{e.message}")
end
end
content_types =
begin
JSON.parse(File.read(configuration.schema_file))['contentTypes'] if File.exist?(configuration.schema_file)
rescue JSON::ParserError
- WCC::Contentful.logger.warn("Schema file invalid, ignoring it: #{configuration.schema_file}")
+ Services.instance.warn("Schema file invalid, ignoring it: #{configuration.schema_file}")
nil
end
if !content_types && %i[if_possible never].include?(configuration.update_schema_file)
# Final fallback - try to grab content types from CDN. We can't update the file
@@ -110,10 +109,10 @@
Services.instance.client
begin
content_types = client.content_types(limit: 1000).items if client
rescue WCC::Contentful::SimpleClient::ApiError => e
# indicates bad credentials
- WCC::Contentful.logger.warn("Unable to load content types from API - #{e.message}")
+ Services.instance.logger.warn("Unable to load content types from API - #{e.message}")
end
end
unless content_types
raise InitializationError, 'Unable to load content types from schema file or API! ' \