Sha256: 3cc6e26c7c12ba76e436d76b170a057b10cd943f505d0e5776843a564c00b7eb

Contents?: true

Size: 904 Bytes

Versions: 64

Compression:

Stored size: 904 Bytes

Contents

# This Resque extension changes the resque default logger to monologger
# and formats the log in json format.
# 
# Monologger supports printing logs in trap block.
# 
module Resque
  module Plugins
    module CustomLogger
      def before_perform(*args)
        case args.class.name
        when "Array"
          if args.first.is_a?(Hash)
            data = args.first.merge({:worker_class => self.to_s})
          else
            data = {:worker_class => self.to_s, :args => args.to_json}
          end
        when "Hash"
          data = args.merge({:worker_class => self.to_s})
        end

        if Rails.logger.is_a?(Ougai::Logger) && !Rails.env.development?
          Rails.logger.with_fields = { zecs_service: data.transform_keys(&:to_sym), trace_id: SecureRandom.uuid }
        end

        if data.present?
          Rails.logger.info('Starting job')
        end
      end
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
zuora_connect-3.2.11 lib/resque/plugins/custom_logger.rb
zuora_connect-3.2.10 lib/resque/plugins/custom_logger.rb
zuora_connect-3.2.9 lib/resque/plugins/custom_logger.rb
zuora_connect-3.2.8 lib/resque/plugins/custom_logger.rb
zuora_connect-3.2.7 lib/resque/plugins/custom_logger.rb
zuora_connect-3.2.6 lib/resque/plugins/custom_logger.rb
zuora_connect-3.2.5 lib/resque/plugins/custom_logger.rb
zuora_connect-3.2.4 lib/resque/plugins/custom_logger.rb
zuora_connect-3.2.3 lib/resque/plugins/custom_logger.rb
zuora_connect-3.2.2 lib/resque/plugins/custom_logger.rb
zuora_connect-3.2.0 lib/resque/plugins/custom_logger.rb
zuora_connect-3.1.5.pre.g lib/resque/plugins/custom_logger.rb
zuora_connect-3.1.5.pre.f lib/resque/plugins/custom_logger.rb
zuora_connect-3.1.5.pre.e lib/resque/plugins/custom_logger.rb
zuora_connect-3.1.5.pre.d lib/resque/plugins/custom_logger.rb
zuora_connect-3.1.5.pre.c lib/resque/plugins/custom_logger.rb
zuora_connect-3.1.5.pre.b lib/resque/plugins/custom_logger.rb
zuora_connect-3.1.5.pre.a lib/resque/plugins/custom_logger.rb
zuora_connect-3.1.5 lib/resque/plugins/custom_logger.rb
zuora_connect-3.1.4 lib/resque/plugins/custom_logger.rb