ezlog 0.9.1 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +66 -0
- data/README.md +1 -0
- data/ezlog.gemspec +2 -1
- data/lib/ezlog/logging_layout.rb +12 -11
- data/lib/ezlog/rails/active_record/log_subscriber.rb +2 -0
- data/lib/ezlog/rails/log_exceptions.rb +7 -1
- data/lib/ezlog/railtie.rb +10 -2
- data/lib/ezlog/rspec/matchers.rb +2 -0
- data/lib/ezlog/sidekiq/death_logger.rb +15 -0
- data/lib/ezlog/sidekiq/job_context.rb +11 -3
- data/lib/ezlog/sidekiq.rb +1 -0
- data/lib/ezlog/version.rb +1 -1
- data/repo-info.json +7 -0
- metadata +23 -11
- data/.gitignore +0 -13
- data/.rspec +0 -3
- data/.travis.yml +0 -9
- data/Rakefile +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4270c3e08d7eed8814bb532011ba89f38e9d01f1c5989d4cf897f1bf346211a
|
4
|
+
data.tar.gz: b29b7da890c056a8fb7e366be8a501ed1aa65d739659de748def920d8befbf8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67c97458aa1e2227496538bbede305710204b19d59ceb76cffe10d41a275ee2772ee7b73f8c2d0fafab4c3ef73d1ec827ad3ce4eef788576f435e4f3e8acf259
|
7
|
+
data.tar.gz: 2fcafa0d0ade63c68aff07fd10d3a92a72c7cde0e19509c62669f30bec46937b842d7ea9c05beaac263d6f2eebbb6db64e94c1cfff3821c9244eed70e52540f3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,69 @@
|
|
1
|
+
### 0.10.1 (2022-01-22)
|
2
|
+
|
3
|
+
[Full Changelog](https://github.com/emartech/ezlog/compare/v0.10.0...v0.10.1)
|
4
|
+
|
5
|
+
* Fix
|
6
|
+
* Fixed a bug where `ActionView::LogSubscriber` was potentially not (eager)loaded by the time we tried to detach it.
|
7
|
+
With this fix Rails 6.1 running on Ruby 3 should be fully supported.
|
8
|
+
|
9
|
+
### 0.10.0 (2021-07-01)
|
10
|
+
|
11
|
+
[Full Changelog](https://github.com/emartech/ezlog/compare/v0.9.6...v0.10.0)
|
12
|
+
|
13
|
+
* Features & enhancements
|
14
|
+
* Do not log exceptions which are handled by Rails. Therefore you can't get false alarms from your exception notifier
|
15
|
+
|
16
|
+
### 0.9.6 (2021-06-30)
|
17
|
+
|
18
|
+
[Full Changelog](https://github.com/emartech/ezlog/compare/v0.9.5...v0.9.6)
|
19
|
+
|
20
|
+
* Fix
|
21
|
+
* fixing a Rails 6.1 specific issue with ActiveRecord array parameter in a query (`User.where(id: [1,2,3,4])`)
|
22
|
+
|
23
|
+
### 0.9.5 (2020-10-01)
|
24
|
+
|
25
|
+
[Full Changelog](https://github.com/emartech/ezlog/compare/v0.9.4...v0.9.5)
|
26
|
+
|
27
|
+
* Fix
|
28
|
+
* fixing an issue with the Sidekiq job's log context generation:
|
29
|
+
using a namespaced Sidekiq worker (`SomeModule::SomeWorker`) cause the log context generations to fail with: `NameError: wrong constant name SomeModule::SomeWorker`
|
30
|
+
|
31
|
+
### 0.9.4 (2020-09-26)
|
32
|
+
|
33
|
+
[Full Changelog](https://github.com/emartech/ezlog/compare/v0.9.3...v0.9.4)
|
34
|
+
|
35
|
+
* Features & enhancements
|
36
|
+
* added Ruby 2.7 to the list of version CI will test the code with
|
37
|
+
* remove dot-files and Rakefile from the gem
|
38
|
+
* Fix
|
39
|
+
* stop using `Hash#merge` with multiple arguments as it's only supported from Ruby 2.6
|
40
|
+
|
41
|
+
### 0.9.3 (2020-09-20)
|
42
|
+
|
43
|
+
[Full Changelog](https://github.com/emartech/ezlog/compare/v0.9.2...v0.9.3)
|
44
|
+
|
45
|
+
* Features & enhancements
|
46
|
+
* Switching to [Oj](https://github.com/ohler55/oj) for fast JSON serialization
|
47
|
+
* Allow level to be formatted (so it can be logged as a number too)
|
48
|
+
|
49
|
+
if you want to use Ougai-like numbers you can do something like this:
|
50
|
+
```ruby
|
51
|
+
config.ezlog.layout_options = { level_formatter: ->(level_number) { (level_number + 2) * 10 } }
|
52
|
+
|
53
|
+
Rails.logger.error('Boom!')
|
54
|
+
#=> {"logger":"Application","timestamp":"2020-09-20T19:29:03+02:00","level":50,"hostname":"BUD010256.local","pid":19872,"message":"Boom!"}
|
55
|
+
```
|
56
|
+
* initial context (a context which will be added to every single line of log) can be configured via `config.ezlog.layout_options` and it defaults to `{environment: ::Rails.env}`
|
57
|
+
|
58
|
+
### 0.9.2 (2020-09-19)
|
59
|
+
|
60
|
+
[Full Changelog](https://github.com/emartech/ezlog/compare/v0.9.1...v0.9.2)
|
61
|
+
|
62
|
+
* Features & enhancements
|
63
|
+
* Improvements of the [Sidekiq](https://github.com/mperham/sidekiq) integration
|
64
|
+
* supports additional job information: batch id, tags and thread id (bid, tags, tid)
|
65
|
+
* support logging "death" events (setting up a death_handler)
|
66
|
+
|
1
67
|
### 0.9.1 (2020-05-10)
|
2
68
|
|
3
69
|
[Full Changelog](https://github.com/emartech/ezlog/compare/v0.9.0...v0.9.1)
|
data/README.md
CHANGED
@@ -93,6 +93,7 @@ In addition to this, Ezlog also does the following:
|
|
93
93
|
* It disables Rails's default logging of uncaught errors and injects its own error logger into the application, which
|
94
94
|
* logs 1 line per error, including the error's name and context (stack trace, etc.),
|
95
95
|
* logs every error at ERROR level instead of the default FATAL.
|
96
|
+
* does not log exceptions which are handled by Rails (`ActionDispatch::ExceptionWrapper.rescue_responses`)
|
96
97
|
* It disables Rails's default request logging, which logs several lines per event during the processing of an action,
|
97
98
|
and replaces the default Rack access log with its own access log middleware. The end result is an access log that
|
98
99
|
* contains all relevant information (request ID, method, path, params, client IP, duration and response status code), and
|
data/ezlog.gemspec
CHANGED
@@ -16,13 +16,14 @@ Gem::Specification.new do |spec|
|
|
16
16
|
}
|
17
17
|
|
18
18
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
19
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^((test|spec|features)/|Rakefile|\.)}) }
|
20
20
|
end
|
21
21
|
spec.bindir = "exe"
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
25
|
spec.add_dependency "logging", "~> 2.0"
|
26
|
+
spec.add_dependency "oj", "~> 3.0"
|
26
27
|
|
27
28
|
spec.add_development_dependency "bundler", "~> 2.0"
|
28
29
|
spec.add_development_dependency "rake", ">= 12.3.3"
|
data/lib/ezlog/logging_layout.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'time'
|
2
|
-
require '
|
2
|
+
require 'oj'
|
3
3
|
|
4
4
|
module Ezlog
|
5
5
|
class LoggingLayout < ::Logging::Layout
|
6
|
-
def initialize(context = {})
|
6
|
+
def initialize(context = {}, options = {})
|
7
7
|
@initial_context = context
|
8
|
+
@level_formatter = options.fetch(:level_formatter, ->(numeric_level) { ::Logging::LNAMES[numeric_level] })
|
8
9
|
end
|
9
10
|
|
10
11
|
def format(event)
|
@@ -12,7 +13,7 @@ module Ezlog
|
|
12
13
|
add_initial_context_to log_entry
|
13
14
|
add_logging_context_to log_entry
|
14
15
|
add_event_information_to log_entry, event
|
15
|
-
::
|
16
|
+
::Oj.dump(log_entry, mode: :json) + "\n"
|
16
17
|
end
|
17
18
|
|
18
19
|
private
|
@@ -20,8 +21,8 @@ module Ezlog
|
|
20
21
|
def basic_information_for(event)
|
21
22
|
{
|
22
23
|
'logger' => event.logger,
|
23
|
-
'timestamp' => event.time.iso8601,
|
24
|
-
'level' =>
|
24
|
+
'timestamp' => event.time.iso8601(3),
|
25
|
+
'level' => @level_formatter.call(event.level),
|
25
26
|
'hostname' => Socket.gethostname,
|
26
27
|
'pid' => Process.pid
|
27
28
|
}
|
@@ -46,17 +47,17 @@ module Ezlog
|
|
46
47
|
when Hash
|
47
48
|
obj
|
48
49
|
else
|
49
|
-
{message
|
50
|
+
{ 'message' => obj }
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
53
54
|
def exception_message_by(exception)
|
54
55
|
{
|
55
|
-
message
|
56
|
-
error
|
57
|
-
class
|
58
|
-
message
|
59
|
-
backtrace
|
56
|
+
'message' => exception.message,
|
57
|
+
'error' => {
|
58
|
+
'class' => exception.class.name,
|
59
|
+
'message' => exception.message,
|
60
|
+
'backtrace' => exception.backtrace&.first(20)
|
60
61
|
}
|
61
62
|
}
|
62
63
|
end
|
@@ -9,9 +9,15 @@ module Ezlog
|
|
9
9
|
def call(env)
|
10
10
|
@app.call(env)
|
11
11
|
rescue Exception => exception
|
12
|
-
@logger.error exception
|
12
|
+
@logger.error exception unless handled?(exception)
|
13
13
|
raise
|
14
14
|
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def handled?(exception)
|
19
|
+
ActionDispatch::ExceptionWrapper.rescue_responses.key? exception.class.name
|
20
|
+
end
|
15
21
|
end
|
16
22
|
end
|
17
23
|
end
|
data/lib/ezlog/railtie.rb
CHANGED
@@ -5,13 +5,17 @@ module Ezlog
|
|
5
5
|
config.ezlog.log_only_whitelisted_params = false
|
6
6
|
config.ezlog.whitelisted_params = [:controller, :action]
|
7
7
|
config.ezlog.exclude_paths = []
|
8
|
+
config.ezlog.initial_context = { environment: ::Rails.env }
|
9
|
+
config.ezlog.layout_options = {}
|
8
10
|
|
9
11
|
initializer "ezlog.initialize" do
|
10
12
|
require "ezlog/rails/extensions"
|
11
13
|
end
|
12
14
|
|
13
15
|
initializer 'ezlog.configure_logging' do |app|
|
14
|
-
::Logging.logger.root.appenders =
|
16
|
+
::Logging.logger.root.appenders =
|
17
|
+
::Logging.appenders.stdout 'stdout', layout: Ezlog::LoggingLayout.new(app.config.ezlog.initial_context,
|
18
|
+
app.config.ezlog.layout_options)
|
15
19
|
::Logging.logger.root.level = app.config.log_level
|
16
20
|
end
|
17
21
|
|
@@ -38,7 +42,10 @@ module Ezlog
|
|
38
42
|
case ::Rails::VERSION::MAJOR
|
39
43
|
when 6
|
40
44
|
::ActionController::LogSubscriber.detach_from :action_controller
|
41
|
-
::ActionView
|
45
|
+
if defined? ::ActionView
|
46
|
+
require 'action_view/log_subscriber' unless defined? ::ActionView::LogSubscriber
|
47
|
+
::ActionView::LogSubscriber.detach_from :action_view
|
48
|
+
end
|
42
49
|
if defined? ::ActiveRecord
|
43
50
|
::ActiveRecord::LogSubscriber.detach_from :active_record
|
44
51
|
Ezlog::Rails::LogSubscriber.attach Ezlog::Rails::ActiveRecord::LogSubscriber, :active_record
|
@@ -67,6 +74,7 @@ module Ezlog
|
|
67
74
|
config.options[:job_logger] = Ezlog::Sidekiq::JobLogger
|
68
75
|
config.error_handlers << Ezlog::Sidekiq::ErrorLogger.new
|
69
76
|
config.error_handlers.delete_if { |handler| handler.is_a? ::Sidekiq::ExceptionHandler::Logger }
|
77
|
+
config.death_handlers << Ezlog::Sidekiq::DeathLogger.new
|
70
78
|
end
|
71
79
|
end
|
72
80
|
|
data/lib/ezlog/rspec/matchers.rb
CHANGED
@@ -4,13 +4,18 @@ module Ezlog
|
|
4
4
|
class << self
|
5
5
|
def from_job_hash(job_hash)
|
6
6
|
return {} if job_hash.nil?
|
7
|
-
basic_info_from(job_hash).merge
|
7
|
+
thread_info.merge(basic_info_from(job_hash)).merge(named_arguments_from(job_hash))
|
8
8
|
end
|
9
9
|
|
10
10
|
private
|
11
11
|
|
12
|
+
def thread_info
|
13
|
+
{ tid: Thread.current['sidekiq_tid'] || (Thread.current.object_id ^ ::Process.pid).to_s(36) }
|
14
|
+
end
|
15
|
+
|
16
|
+
|
12
17
|
def basic_info_from(job)
|
13
|
-
{
|
18
|
+
h = {
|
14
19
|
jid: job['jid'],
|
15
20
|
queue: job['queue'],
|
16
21
|
worker: job_class(job),
|
@@ -18,6 +23,9 @@ module Ezlog
|
|
18
23
|
enqueued_at: job['enqueued_at'],
|
19
24
|
run_count: (job['retry_count'] || -1) + 2
|
20
25
|
}
|
26
|
+
h[:bid] = job['bid'] if job['bid']
|
27
|
+
h[:tags] = job['tags'] if job['tags']
|
28
|
+
h
|
21
29
|
end
|
22
30
|
|
23
31
|
def named_arguments_from(job)
|
@@ -29,7 +37,7 @@ module Ezlog
|
|
29
37
|
end
|
30
38
|
|
31
39
|
def method_parameters_of(job)
|
32
|
-
Kernel.const_get(job_class(job)
|
40
|
+
Kernel.const_get(job_class(job)).instance_method(:perform).parameters
|
33
41
|
end
|
34
42
|
|
35
43
|
def job_class(job)
|
data/lib/ezlog/sidekiq.rb
CHANGED
data/lib/ezlog/version.rb
CHANGED
data/repo-info.json
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ezlog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zoltan Ormandi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: oj
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,21 +136,17 @@ dependencies:
|
|
122
136
|
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '5.0'
|
125
|
-
description:
|
139
|
+
description:
|
126
140
|
email:
|
127
141
|
- zoltan.ormandi@emarsys.com
|
128
142
|
executables: []
|
129
143
|
extensions: []
|
130
144
|
extra_rdoc_files: []
|
131
145
|
files:
|
132
|
-
- ".gitignore"
|
133
|
-
- ".rspec"
|
134
|
-
- ".travis.yml"
|
135
146
|
- CHANGELOG.md
|
136
147
|
- Gemfile
|
137
148
|
- LICENSE.txt
|
138
149
|
- README.md
|
139
|
-
- Rakefile
|
140
150
|
- bin/console
|
141
151
|
- bin/setup
|
142
152
|
- ezlog.gemspec
|
@@ -156,17 +166,19 @@ files:
|
|
156
166
|
- lib/ezlog/rspec/helpers.rb
|
157
167
|
- lib/ezlog/rspec/matchers.rb
|
158
168
|
- lib/ezlog/sidekiq.rb
|
169
|
+
- lib/ezlog/sidekiq/death_logger.rb
|
159
170
|
- lib/ezlog/sidekiq/error_logger.rb
|
160
171
|
- lib/ezlog/sidekiq/job_context.rb
|
161
172
|
- lib/ezlog/sidekiq/job_logger.rb
|
162
173
|
- lib/ezlog/version.rb
|
163
174
|
- lib/sequel/extensions/ezlog_logging.rb
|
175
|
+
- repo-info.json
|
164
176
|
homepage: https://github.com/emartech/ezlog
|
165
177
|
licenses:
|
166
178
|
- MIT
|
167
179
|
metadata:
|
168
180
|
changelog_uri: https://github.com/emartech/ezlog/blob/master/CHANGELOG.md
|
169
|
-
post_install_message:
|
181
|
+
post_install_message:
|
170
182
|
rdoc_options: []
|
171
183
|
require_paths:
|
172
184
|
- lib
|
@@ -181,8 +193,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
193
|
- !ruby/object:Gem::Version
|
182
194
|
version: '0'
|
183
195
|
requirements: []
|
184
|
-
rubygems_version: 3.
|
185
|
-
signing_key:
|
196
|
+
rubygems_version: 3.2.22
|
197
|
+
signing_key:
|
186
198
|
specification_version: 4
|
187
199
|
summary: A zero-configuration logging solution for projects using Sidekiq, Rails,
|
188
200
|
Sequel, etc.
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED