ezlog 0.9.1 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +44 -0
- data/ezlog.gemspec +2 -1
- data/lib/ezlog/logging_layout.rb +12 -11
- data/lib/ezlog/railtie.rb +6 -1
- data/lib/ezlog/sidekiq.rb +1 -0
- data/lib/ezlog/sidekiq/death_logger.rb +15 -0
- data/lib/ezlog/sidekiq/job_context.rb +11 -3
- data/lib/ezlog/version.rb +1 -1
- metadata +22 -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: 70fb33130f877332e30cbad096c74d1eeed80bba66f8c9ebedf0854f73bf95aa
|
4
|
+
data.tar.gz: 6bcb5959c18eb00a5065a86dd99ac02b193e8fb693cd195b201bdb07bc5e1fe4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9675aea648f31869dfc248199f05cae2dad3b62aed3352c9383d7626d70cf5a7a0c302b58ddb74f04c45c6177a64e94d46ed84dcf2af55f44eba3c0c22b83ae
|
7
|
+
data.tar.gz: '092a73292dd85f7e8bb918b01a2e972f6c828984aaaf1230f580b456134e94f428948e61212231ee9576b11d92b44cb706ce4f54af8fd735c1eb1074f2a90e67'
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,47 @@
|
|
1
|
+
### 0.9.5 (2020-10-1)
|
2
|
+
|
3
|
+
[Full Changelog](https://github.com/emartech/ezlog/compare/v0.9.4...v0.9.5)
|
4
|
+
|
5
|
+
* Fix
|
6
|
+
* fixing an issue with the Sidekiq job's log context generation:
|
7
|
+
using a namespaced Sidekiq worker (`SomeModule::SomeWorker`) cause the log context generations to fail with: `NameError: wrong constant name SomeModule::SomeWorker`
|
8
|
+
|
9
|
+
### 0.9.4 (2020-09-26)
|
10
|
+
|
11
|
+
[Full Changelog](https://github.com/emartech/ezlog/compare/v0.9.3...v0.9.4)
|
12
|
+
|
13
|
+
* Features & enhancements
|
14
|
+
* added Ruby 2.7 to the list of version CI will test the code with
|
15
|
+
* remove dot-files and Rakefile from the gem
|
16
|
+
* Fix
|
17
|
+
* stop using `Hash#merge` with multiple arguments as it's only supported from Ruby 2.6
|
18
|
+
|
19
|
+
### 0.9.3 (2020-09-20)
|
20
|
+
|
21
|
+
[Full Changelog](https://github.com/emartech/ezlog/compare/v0.9.2...v0.9.3)
|
22
|
+
|
23
|
+
* Features & enhancements
|
24
|
+
* Switching to [Oj](https://github.com/ohler55/oj) for fast JSON serialization
|
25
|
+
* Allow level to be formatted (so it can be logged as a number too)
|
26
|
+
|
27
|
+
if you want to use Ougai-like numbers you can do something like this:
|
28
|
+
```ruby
|
29
|
+
config.ezlog.layout_options = { level_formatter: ->(level_number) { (level_number + 2) * 10 } }
|
30
|
+
|
31
|
+
Rails.logger.error('Boom!')
|
32
|
+
#=> {"logger":"Application","timestamp":"2020-09-20T19:29:03+02:00","level":50,"hostname":"BUD010256.local","pid":19872,"message":"Boom!"}
|
33
|
+
```
|
34
|
+
* 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}`
|
35
|
+
|
36
|
+
### 0.9.2 (2020-09-19)
|
37
|
+
|
38
|
+
[Full Changelog](https://github.com/emartech/ezlog/compare/v0.9.1...v0.9.2)
|
39
|
+
|
40
|
+
* Features & enhancements
|
41
|
+
* Improvements of the [Sidekiq](https://github.com/mperham/sidekiq) integration
|
42
|
+
* supports additional job information: batch id, tags and thread id (bid, tags, tid)
|
43
|
+
* support logging "death" events (setting up a death_handler)
|
44
|
+
|
1
45
|
### 0.9.1 (2020-05-10)
|
2
46
|
|
3
47
|
[Full Changelog](https://github.com/emartech/ezlog/compare/v0.9.0...v0.9.1)
|
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
|
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
|
|
@@ -67,6 +71,7 @@ module Ezlog
|
|
67
71
|
config.options[:job_logger] = Ezlog::Sidekiq::JobLogger
|
68
72
|
config.error_handlers << Ezlog::Sidekiq::ErrorLogger.new
|
69
73
|
config.error_handlers.delete_if { |handler| handler.is_a? ::Sidekiq::ExceptionHandler::Logger }
|
74
|
+
config.death_handlers << Ezlog::Sidekiq::DeathLogger.new
|
70
75
|
end
|
71
76
|
end
|
72
77
|
|
data/lib/ezlog/sidekiq.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/version.rb
CHANGED
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.9.
|
4
|
+
version: 0.9.5
|
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: 2020-
|
11
|
+
date: 2020-10-06 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,6 +166,7 @@ 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
|
@@ -166,7 +177,7 @@ licenses:
|
|
166
177
|
- MIT
|
167
178
|
metadata:
|
168
179
|
changelog_uri: https://github.com/emartech/ezlog/blob/master/CHANGELOG.md
|
169
|
-
post_install_message:
|
180
|
+
post_install_message:
|
170
181
|
rdoc_options: []
|
171
182
|
require_paths:
|
172
183
|
- lib
|
@@ -181,8 +192,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
192
|
- !ruby/object:Gem::Version
|
182
193
|
version: '0'
|
183
194
|
requirements: []
|
184
|
-
rubygems_version: 3.
|
185
|
-
signing_key:
|
195
|
+
rubygems_version: 3.1.2
|
196
|
+
signing_key:
|
186
197
|
specification_version: 4
|
187
198
|
summary: A zero-configuration logging solution for projects using Sidekiq, Rails,
|
188
199
|
Sequel, etc.
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED