Skip to content

Commit

Permalink
add debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
archfish committed Dec 31, 2019
1 parent 44650af commit 8555284
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/mqjob/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Mqjob
VERSION = "0.3.8"
VERSION = "0.3.9"
end
3 changes: 3 additions & 0 deletions lib/mqjob/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def do_work(cmd, msg)
end

def run
Mqjob.logger.debug("#{self.class.name}::#{__method__}"){'trigger'}
@mq.listen(@topic, self, @topic_opts)
end

Expand All @@ -38,8 +39,10 @@ def process_work(cmd, msg)
result = nil
begin
result = if respond_to?(:perform_full_msg)
Mqjob.logger.info(__method__){"perform_full_msg: #{msg.inspect}"}
perform_full_msg(cmd, msg)
else
Mqjob.logger.info(__method__){"perform: #{msg.payload.inspect}"}
perform(msg.payload)
end
rescue => exp
Expand Down
2 changes: 2 additions & 0 deletions lib/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def client(c, plugin: nil)
def init_plugin(name)
name ||= Mqjob.config.plugin

Mqjob.logger.debug("#{self.name}::#{__method__}"){"select plugin: #{name}"}

require "plugin/#{name}"

name.to_s.capitalize
Expand Down
2 changes: 1 addition & 1 deletion lib/plugin/pulsar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Plugin
class Pulsar < Base
def listen(topic, worker, opts = {})
create_consumer(topic, opts).listen do |cmd, msg|
Mqjob.logger.debug("#{self.class.name}::#{__method__}"){msg.payload}
Mqjob.logger.debug("#{self.class.name}::#{__method__}"){"receive msg: #{msg.payload}"}
worker.do_work(cmd, msg)
end
end
Expand Down

0 comments on commit 8555284

Please sign in to comment.