Sha256: 0d3ff76b04e25971b97f8b6977d2e394ee3dcdfbcc3b29bb5270a776e91f3a3e

Contents?: true

Size: 769 Bytes

Versions: 5

Compression:

Stored size: 769 Bytes

Contents

module Pallets
  module Middleware
    class JobLogger
      def self.call(worker, job, context)
        Pallets.logger.info 'Started', extract_metadata(worker.id, job)
        result = yield
        Pallets.logger.info 'Done', extract_metadata(worker.id, job)
        result
      rescue => ex
        Pallets.logger.warn "#{ex.class.name}: #{ex.message}", extract_metadata(worker.id, job)
        Pallets.logger.warn ex.backtrace.join("\n"), extract_metadata(worker.id, job) unless ex.backtrace.nil?
        raise
      end

      def self.extract_metadata(wid, job)
        {
          wid:  wid,
          wfid: job['wfid'],
          jid:  job['jid'],
          wf:   job['workflow_class'],
          tsk:  job['task_class'],
        }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pallets-0.8.0 lib/pallets/middleware/job_logger.rb
pallets-0.7.0 lib/pallets/middleware/job_logger.rb
pallets-0.6.0 lib/pallets/middleware/job_logger.rb
pallets-0.5.1 lib/pallets/middleware/job_logger.rb
pallets-0.5.0 lib/pallets/middleware/job_logger.rb