log4r-exceptionable 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ 0.5.4 (06/15/2012)
2
+ ------------------
3
+
4
+ fix header <8e2164b>
5
+ leave formatting up to log4r <e9a7baf>
6
+
1
7
  0.5.3 (06/15/2012)
2
8
  ------------------
3
9
 
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
- graylog2-resque
2
- ===============
1
+ log4r-exceptionable
2
+ ===================
3
3
 
4
4
  This gem provides failure handlers for [Resque][0] and [Rack][1] that logs all failures using [log4r][2]. It is expected that these logs will get sent elsewhere (e.g. [graylog][3]) by using log4r outputters (e.g. [log4r-gelf][4]). It adds contextual information to the log message using Log4r::MDC, which is useful if you are using log4r-gelf since it sends all of those to graylog as custom attributes.
5
5
 
@@ -44,7 +44,7 @@ module Log4rExceptionable
44
44
  if env and env.size > 0
45
45
  env.each do |k, v|
46
46
  begin
47
- mdc.put("rack_env_#{k}", v.inspect)
47
+ mdc.put("rack_env_#{k}", v)
48
48
  rescue
49
49
  puts "Log4r Exceptionable could not extract a rack env item: " + e.message
50
50
  end
@@ -55,8 +55,8 @@ module Log4rExceptionable
55
55
  if controller && controller.respond_to?(:logger) && controller.logger.instance_of?(Log4r::Logger)
56
56
  error_logger = controller.logger
57
57
  begin
58
- mdc.put("rack_controller_name", controller.controller_name.to_s)
59
- mdc.put("rack_action_name", controller.action_name.to_s)
58
+ mdc.put("rack_controller_name", controller.controller_name)
59
+ mdc.put("rack_action_name", controller.action_name)
60
60
  rescue => e
61
61
  puts "Log4r Exceptionable could not extract controller names: " + e.message
62
62
  end
@@ -12,17 +12,19 @@ module Log4rExceptionable
12
12
  original_mdc = mdc.get_context
13
13
 
14
14
  begin
15
-
15
+
16
16
  data = payload.clone
17
- mdc.put("resque_worker", worker.to_s)
18
- mdc.put("resque_queue", queue.to_s)
19
- mdc.put("resque_class", data.delete('class').to_s)
20
- mdc.put("resque_args", data.delete('args').inspect.to_s)
17
+ payload_class_name = data.delete('class')
18
+ payload_class = Resque.constantize(payload_class_name) rescue payload_class_name
19
+ mdc.put("resque_worker", worker)
20
+ mdc.put("resque_queue", queue)
21
+ mdc.put("resque_class", payload_class)
22
+ mdc.put("resque_args", data.delete('args'))
21
23
 
22
24
  # add in any extra payload data, in case resque plugins have
23
25
  # added to it (e.g. resque-lifecycle)
24
26
  data.each do |k, v|
25
- mdc.put("resque_payload_#{k}", v.inspect.to_s)
27
+ mdc.put("resque_payload_#{k}", v)
26
28
  end
27
29
 
28
30
  payload_class = Resque.constantize(payload['class']) rescue nil
@@ -1,3 +1,3 @@
1
1
  module Log4rExceptionable
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
3
3
  end
@@ -74,7 +74,7 @@ describe Log4rExceptionable::RackFailureHandler do
74
74
  msg.should be_instance_of RuntimeError
75
75
  msg.message.should == "I failed"
76
76
  msg.backtrace.first.should =~ /rack_failure_handler_spec.rb/
77
- Log4r::MDC.get('rack_env_PATH_INFO').should == '"/error"'
77
+ Log4r::MDC.get('rack_env_PATH_INFO').should == '/error'
78
78
  end
79
79
 
80
80
  lambda {
@@ -55,10 +55,10 @@ describe Log4rExceptionable::ResqueFailureHandler do
55
55
  msg.should be_instance_of RuntimeError
56
56
  msg.message.should == "I failed"
57
57
  msg.backtrace.first.should =~ /resque_failure_handler_spec.rb/
58
- Log4r::MDC.get('resque_worker').should == ""
58
+ Log4r::MDC.get('resque_worker').should == nil
59
59
  Log4r::MDC.get('resque_queue').should == "somequeue"
60
- Log4r::MDC.get('resque_class').should == "SomeJob"
61
- Log4r::MDC.get('resque_args').should == "[\"foo\"]"
60
+ Log4r::MDC.get('resque_class').should == SomeJob
61
+ Log4r::MDC.get('resque_args').should == ["foo"]
62
62
  end
63
63
 
64
64
  run_resque_job(SomeJob, 'foo', :queue => :somequeue, :inline => true)
@@ -69,7 +69,7 @@ describe Log4rExceptionable::ResqueFailureHandler do
69
69
  Log4r::Logger['resquelogger'].should_receive(:error) do |msg|
70
70
  msg.should be_instance_of RuntimeError
71
71
  msg.message.should == "I failed"
72
- Log4r::MDC.get('resque_class').should == "SomeJobWithNilLogger"
72
+ Log4r::MDC.get('resque_class').should == SomeJobWithNilLogger
73
73
  end
74
74
 
75
75
  run_resque_job(SomeJobWithNilLogger, 'foo', :queue => :somequeue, :inline => true)
@@ -80,7 +80,7 @@ describe Log4rExceptionable::ResqueFailureHandler do
80
80
  Log4r::Logger['resquelogger'].should_receive(:error) do |msg|
81
81
  msg.should be_instance_of RuntimeError
82
82
  msg.message.should == "I failed"
83
- Log4r::MDC.get('resque_class').should == "SomeJobWithOtherLogger"
83
+ Log4r::MDC.get('resque_class').should == SomeJobWithOtherLogger
84
84
  end
85
85
 
86
86
  run_resque_job(SomeJobWithOtherLogger, 'foo', :queue => :somequeue, :inline => true)
@@ -92,7 +92,7 @@ describe Log4rExceptionable::ResqueFailureHandler do
92
92
  Log4r::Logger['SomeJobWithLogger'].should_receive(:error) do |msg|
93
93
  msg.should be_instance_of RuntimeError
94
94
  msg.message.should == "I failed"
95
- Log4r::MDC.get('resque_class').should == "SomeJobWithLogger"
95
+ Log4r::MDC.get('resque_class').should == SomeJobWithLogger
96
96
  end
97
97
 
98
98
  run_resque_job(SomeJobWithLogger, 'foo', :queue => :somequeue, :inline => true)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log4r-exceptionable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: