rails_lograge_middleware 1.0.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5474072216e5302f87b4d1b8bc3eadb97316441c
4
- data.tar.gz: a10c24e56dd48b1d682102bc2013408f58353586
3
+ metadata.gz: c732738ab67372a91d37ab2a3eba160575a87840
4
+ data.tar.gz: 63cf6b78e5242b3b459a4f8b4fe5cc73db8d8f15
5
5
  SHA512:
6
- metadata.gz: ea73c62c56f92ac78eefebdabebf43c9e2cae6fa7f105c9f3a0e9648c5137293f2e25851bb56fee68403d31df9b8073d47bdeca40a67da8ab75b5d5f941add84
7
- data.tar.gz: d7a75089cfe0c4457e1d687299060c93a6e7fbe4a08059ba3b0d1c457d5c585c21c872c5cdc6143c681a7c990a1db03280a5f377f075fc515f0d26750a677a84
6
+ metadata.gz: e21b520499ad8398e99ecb4b4b94e0440482f95b28a96de005a1b3e3b4b0c6dbb806a810fa3a0fdd017dc1cc5df93ee377c0cc996b7c7f6a45e720e574675e86
7
+ data.tar.gz: 34052404a9dc419913065c47eb654f8d033e86b5ad0f8e397b59a28a88d0dfbbdf7fcfe93a58ae82c252aec40bf9b90dc42ab383192ee55393c001f0e7ceeee5
@@ -0,0 +1,30 @@
1
+ module RailsLogrageMiddleware
2
+ module ActiveJob
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ rescue_from(Exception) do |exception|
7
+ log_exception(exception)
8
+
9
+ raise exception
10
+ end
11
+
12
+ def log_exception(exception)
13
+ entry = {
14
+ job_name: self.class.name,
15
+ job_id: self.job_id,
16
+ queue_name: self.queue_name
17
+ }
18
+ entry[:message] = "Job #{entry[:job_name]} failed #{exception.to_s}"
19
+ entry[:exception] = "#{exception.to_s} at #{exception.backtrace.first.strip}"
20
+
21
+ if Rails.configuration.rails_lograge_middleware.active_job_custom_options
22
+ custom_options = Rails.configuration.rails_lograge_middleware.active_job_custom_options.call(exception, self)
23
+ entry.merge! custom_options
24
+ end
25
+
26
+ Lograge.logger.presence.error Rails.configuration.lograge.formatter.call(entry)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -32,10 +32,10 @@ module RailsLogrageMiddleware
32
32
  entry[:message] = "Error on #{entry[:path]} (#{entry[:controller]}##{entry[:action]}) #{exception.to_s}"
33
33
  entry[:exception] = "#{exception.to_s} at #{exception.backtrace.first.strip}"
34
34
 
35
- return unless entry
36
-
37
- custom_options = Rails.configuration.rails_lograge_middleware.custom_options.call(exception, env, request)
38
- entry.merge! custom_options
35
+ if Rails.configuration.rails_lograge_middleware.custom_options
36
+ custom_options = Rails.configuration.rails_lograge_middleware.custom_options.call(exception, env, request)
37
+ entry.merge! custom_options
38
+ end
39
39
 
40
40
  Lograge.logger.presence.error Rails.configuration.lograge.formatter.call(entry)
41
41
  end
@@ -1,7 +1,7 @@
1
1
  require 'rails/railtie'
2
2
 
3
3
  module RailsLogrageMiddleware
4
- Config = Struct.new(:custom_options)
4
+ Config = Struct.new(:custom_options, :active_job_custom_options)
5
5
 
6
6
  class Railtie < Rails::Railtie
7
7
  config.rails_lograge_middleware = Config.new
@@ -9,5 +9,12 @@ module RailsLogrageMiddleware
9
9
  initializer 'rails_lograge_middleware.configure_middleware' do |app|
10
10
  app.middleware.use Middleware
11
11
  end
12
+
13
+ initializer('rails_lograge_middleware.active_job') do
14
+ ActiveSupport.on_load(:active_job) do
15
+ require 'rails_lograge_middleware/active_job'
16
+ include RailsLogrageMiddleware::ActiveJob
17
+ end
18
+ end
12
19
  end
13
20
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_lograge_middleware
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michał Zalewski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-01 00:00:00.000000000 Z
11
+ date: 2016-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '3.5'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '3.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -86,6 +86,7 @@ extensions: []
86
86
  extra_rdoc_files: []
87
87
  files:
88
88
  - lib/rails_lograge_middleware.rb
89
+ - lib/rails_lograge_middleware/active_job.rb
89
90
  - lib/rails_lograge_middleware/middleware.rb
90
91
  - lib/rails_lograge_middleware/railtie.rb
91
92
  - lib/rails_lograge_middleware/version.rb