lib/google_pubsub_enhancer/middleware/publisher.rb in google-pubsub-enhancer-0.4.0 vs lib/google_pubsub_enhancer/middleware/publisher.rb in google-pubsub-enhancer-0.4.1
- old
+ new
@@ -3,13 +3,15 @@
def initialize(app, opts={})
@app = app
@short_topic_name = opts[:short_topic_name] || raise
@full_topic_name = GooglePubsubEnhancer.name_by('topics',@short_topic_name)
@messages_key = opts[:messages] || raise
+ @logger = opts[:logger] || Logger.new(STDOUT)
@google_cloud_pubsub ||= Google::Cloud::Pubsub.new
end
def call(env)
+ @logger.debug("#{env[@messages_key].length} messages published")
@google_cloud_pubsub.publish(@full_topic_name) do |publisher|
[*env[@messages_key]].each do |m|
publisher.publish(m)
end
end