Sha256: f89edfc127988a8bb12e15ac55c7612c46808555e7758480a8741f74e9826faf

Contents?: true

Size: 961 Bytes

Versions: 4

Compression:

Stored size: 961 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

4 entries across 4 versions & 1 rubygems

Version Path
rocketjob-3.4.3 lib/rocket_job/plugins/job/logger.rb
rocketjob-3.4.2 lib/rocket_job/plugins/job/logger.rb
rocketjob-3.4.1 lib/rocket_job/plugins/job/logger.rb
rocketjob-3.4.0 lib/rocket_job/plugins/job/logger.rb