Sha256: b476f036287cba2008fa646150e4ff017cf7dffdcec6d577af3ddf1cff66a356

Contents?: true

Size: 960 Bytes

Versions: 17

Compression:

Stored size: 960 Bytes

Contents

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.measure_info(
            'Completed #perform',
            metric:             "#{self.class.name}/perform",
            log_exception:      :full,
            on_exception_level: :error,
            silence:            log_level,
            &block
          )
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rocketjob-5.1.1 lib/rocket_job/plugins/job/logger.rb
rocketjob-5.1.0 lib/rocket_job/plugins/job/logger.rb
rocketjob-5.0.0 lib/rocket_job/plugins/job/logger.rb
rocketjob-5.0.0.rc1 lib/rocket_job/plugins/job/logger.rb
rocketjob-5.0.0.beta4 lib/rocket_job/plugins/job/logger.rb
rocketjob-5.0.0.beta3 lib/rocket_job/plugins/job/logger.rb
rocketjob-5.0.0.beta2 lib/rocket_job/plugins/job/logger.rb
rocketjob-5.0.0.beta lib/rocket_job/plugins/job/logger.rb
rocketjob-4.3.0.beta2 lib/rocket_job/plugins/job/logger.rb
rocketjob-4.3.0.beta lib/rocket_job/plugins/job/logger.rb
rocketjob-4.2.0 lib/rocket_job/plugins/job/logger.rb
rocketjob-4.1.1 lib/rocket_job/plugins/job/logger.rb
rocketjob-4.1.0 lib/rocket_job/plugins/job/logger.rb
rocketjob-4.0.0 lib/rocket_job/plugins/job/logger.rb
rocketjob-3.5.2 lib/rocket_job/plugins/job/logger.rb
rocketjob-3.5.1 lib/rocket_job/plugins/job/logger.rb
rocketjob-3.5.0 lib/rocket_job/plugins/job/logger.rb