Class: Log4rExceptionable::ResqueFailureHandler
- Inherits:
-
Resque::Failure::Base
- Object
- Resque::Failure::Base
- Log4rExceptionable::ResqueFailureHandler
- Includes:
- Helper
- Defined in:
- lib/log4r-exceptionable/resque_failure_handler.rb
Overview
A Resque Failure backend that logs exceptions with log4r
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Helper
#add_context, #log_with_context
Class Method Details
.count ⇒ Object
44 45 46 47 48 |
# File 'lib/log4r-exceptionable/resque_failure_handler.rb', line 44 def self.count # We can't get the total # of errors from graylog so we fake it # by asking Resque how many errors it has seen. ::Resque::Stat[:failed] end |
Instance Method Details
#save ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/log4r-exceptionable/resque_failure_handler.rb', line 10 def save log_with_context do |context| data = payload.clone payload_class_name = data.delete('class') payload_class = Resque.constantize(payload_class_name) rescue payload_class_name add_context(context, "resque_worker", worker) add_context(context, "resque_queue", queue) add_context(context, "resque_class", payload_class) add_context(context, "resque_args", data.delete('args')) # add in any extra payload data, in case resque plugins have # added to it (e.g. resque-lifecycle) data.each do |k, v| add_context(context, "resque_payload_#{k}", v) end error_logger = nil if Log4rExceptionable::Configuration.use_source_logger payload_class = Resque.constantize(payload['class']) rescue nil if payload_class && payload_class.respond_to?(:logger) && payload_class.logger.instance_of?(Log4r::Logger) error_logger = payload_class.logger end end error_logger ||= Log4rExceptionable::Configuration.resque_failure_logger error_logger.send(Log4rExceptionable::Configuration.log_level, exception) end end |