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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c732738ab67372a91d37ab2a3eba160575a87840
|
4
|
+
data.tar.gz: 63cf6b78e5242b3b459a4f8b4fe5cc73db8d8f15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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.
|
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-
|
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: '
|
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: '
|
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
|