lib/google_pubsub_enhancer.rb in google-pubsub-enhancer-0.3.0 vs lib/google_pubsub_enhancer.rb in google-pubsub-enhancer-0.4.0
- old
+ new
@@ -1,8 +1,9 @@
require 'json'
require 'middleware'
require 'google/cloud/pubsub'
+require 'logger'
class GooglePubsubEnhancer
require 'google_pubsub_enhancer/constants'
require 'google_pubsub_enhancer/middleware'
@@ -20,18 +21,20 @@
rescue => ex
raise Exception, 'Environment not setted properly'
end
end
- def initialize(&block)
+ def initialize(logger: Logger.new(STDOUT),&block)
+ @logger = logger
@stack = ::Middleware::Builder.new(&block).__send__(:to_app)
end
def run(subscription_short_name, opts={})
configurated_options = configurate_options(opts)
subscription = create_subscription(subscription_short_name)
work(subscription, configurated_options)
- rescue
+ rescue => ex
+ @logger.error "Retry: #{ex} "
retry
end
private