Sha256: 90fedddf535a944adc065f222ac8480997c62a0317575aa31a4a49b7eff7c31f

Contents?: true

Size: 1002 Bytes

Versions: 3

Compression:

Stored size: 1002 Bytes

Contents

# encoding: UTF-8
require 'active_support/concern'

module RocketJob
  module Plugins
    module Job
      module Logger
        extend ActiveSupport::Concern

        included do
          around_perform :rocket_job_around_logger
        end

        private

        # Add logging around the perform call
        #   - metric allows duration to be forwarded to statsd, etc.
        #   - log_exception logs entire exception if raised
        #   - on_exception_level changes log level from info to error on exception
        #   - silence noisy jobs by raising log level
        def rocket_job_around_logger(&block)
          logger.info('Start #perform')
          logger.benchmark_info(
            'Completed #perform',
            metric:             "rocketjob/#{self.class.name.underscore}/perform",
            log_exception:      :full,
            on_exception_level: :error,
            silence:            log_level,
            &block
          )
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rocketjob-2.0.0.rc3 lib/rocket_job/plugins/job/logger.rb
rocketjob-2.0.0.rc2 lib/rocket_job/plugins/job/logger.rb
rocketjob-2.0.0.rc1 lib/rocket_job/plugins/job/logger.rb