lorekeeper 1.11.1 → 2.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 +4 -4
- data/.github/workflows/build.yml +29 -0
- data/CHANGELOG.md +12 -0
- data/README.md +18 -4
- data/lib/lorekeeper/json_logger.rb +3 -3
- data/lib/lorekeeper/simple_logger.rb +22 -7
- data/lib/lorekeeper/version.rb +1 -1
- data/lorekeeper.gemspec +2 -2
- metadata +6 -6
- data/.travis.yml +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8a5d046cc9e67c4efda44b74aa45acd384a49d58b1ea710799ff072de7b0316
|
4
|
+
data.tar.gz: c095a976184d6456d2605fdebc25ed20e31b992672e066b892b08be201fe70c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76c142c27abbae12ec4e5bde2262ea79f962f0e5aa9ac6074c04fdf7b84cdc3d5c62cdfdaae45874589d53300de2ddc961657562d9abffbbec8501575ae9f2d6
|
7
|
+
data.tar.gz: 3e86217440ba8269f05c1a1ec44bc4262067a9608ee7caab4a35cfc222a8870a2e7bfbb51dd275ea42ee7169cc033d79ee692dd469f5e16b9a21ae04af348803
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: build
|
9
|
+
|
10
|
+
on: [push, pull_request]
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
test:
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
strategy:
|
16
|
+
matrix:
|
17
|
+
ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1']
|
18
|
+
|
19
|
+
steps:
|
20
|
+
- uses: actions/checkout@v2
|
21
|
+
- name: Set up Ruby
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: ${{ matrix.ruby-version }}
|
25
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
26
|
+
- name: Run tests
|
27
|
+
run: bundle exec rspec
|
28
|
+
- name: Run benchmark
|
29
|
+
run: bundle exec rake benchmark
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# 2.1.0
|
2
|
+
* Modify SimpleLogger to properly log exceptions with named parameters
|
3
|
+
|
4
|
+
# 2.0.0
|
5
|
+
* Set `mode: :compat` in Oj.dump to stringify keys
|
6
|
+
* Support Ruby 3.1
|
7
|
+
* Drop support for Ruby < 2.5.0
|
8
|
+
|
9
|
+
# 1.12.0
|
10
|
+
* Remove ZipkinTracer information from stacktrace output
|
11
|
+
* Move CI to GitHub Actions
|
12
|
+
|
1
13
|
# 1.11.1
|
2
14
|
* Modify FastLogger#add to log progname as a message if no message and block are given
|
3
15
|
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Lorekeeper
|
2
2
|
|
3
|
-
[](https://github.com/JordiPolo/lorekeeper/actions/workflows/build.yml)
|
4
4
|
|
5
5
|
LoreKeeper contains a highly optimized JSON logger. It outputs messages as JSON and let the users to add their own customized fields.
|
6
6
|
When used without extra fields it outputs 20% faster than the standard Logger for messages not longer than one line of text.
|
@@ -141,7 +141,7 @@ Will output:
|
|
141
141
|
}
|
142
142
|
```
|
143
143
|
|
144
|
-
This method also accepts a custom message, data and log level
|
144
|
+
This method also accepts a custom message, data and log level:
|
145
145
|
|
146
146
|
```ruby
|
147
147
|
rescue => e
|
@@ -169,16 +169,30 @@ Will output:
|
|
169
169
|
}
|
170
170
|
```
|
171
171
|
|
172
|
-
|
172
|
+
Please note that due to the way Ruby 2.x automatically converts Hash objects to keyword arguments when they come last,
|
173
|
+
you need to explicitly use the `data` keyword argument when you don't pass any other argument afterwards:
|
173
174
|
|
174
175
|
|
176
|
+
```ruby
|
177
|
+
logger.exception(e, "custom msg!", { some: { data: 123 } })
|
178
|
+
# => ArgumentError: unknown keyword: some
|
179
|
+
|
180
|
+
logger.exception(e, "custom msg!", data: { some: { data: 123 } })
|
181
|
+
# => works
|
182
|
+
```
|
183
|
+
|
184
|
+
Ruby 3.x is unaffected by this issue since the conversion is [not done automatically anymore](https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/).
|
185
|
+
|
186
|
+
|
187
|
+
The available keyword arguments are `message`, `data` and `level`. They can be used instead of the fixed arguments:
|
188
|
+
|
175
189
|
```ruby
|
176
190
|
rescue => e
|
177
191
|
logger.exception(e, message: "custom msg!", data: { some: { data: 123 } }, level: :warn)
|
178
192
|
end
|
179
193
|
```
|
180
194
|
|
181
|
-
This is
|
195
|
+
This is especially useful when there is no custom message or data:
|
182
196
|
|
183
197
|
```ruby
|
184
198
|
rescue => e
|
@@ -98,7 +98,7 @@ module Lorekeeper
|
|
98
98
|
|
99
99
|
# Some instrumentation libraries pollute the stacktrace and create a large output which may
|
100
100
|
# cause problems with certain logging backends.
|
101
|
-
# Hardcording newrelic
|
101
|
+
# Hardcording newrelic, active_support/callbacks and zipkin-tracer now here.
|
102
102
|
# In the future if this list grows, we may make it configurable.
|
103
103
|
def clean_backtrace(backtrace)
|
104
104
|
@backtrace_cleaner&.clean(backtrace) || backtrace
|
@@ -121,7 +121,7 @@ module Lorekeeper
|
|
121
121
|
EXCEPTION = 'exception'
|
122
122
|
STACK = 'stack'
|
123
123
|
DATA = 'data'
|
124
|
-
BLACKLISTED_FINGERPRINT = %r{newrelic_rpm|active_support/callbacks.rb}.freeze
|
124
|
+
BLACKLISTED_FINGERPRINT = %r{newrelic_rpm|active_support/callbacks.rb|zipkin-tracer}.freeze
|
125
125
|
|
126
126
|
def with_extra_fields(fields)
|
127
127
|
state[:extra_fields] = fields
|
@@ -148,7 +148,7 @@ module Lorekeeper
|
|
148
148
|
fields_to_log[TIMESTAMP] = Time.now.utc.strftime(DATE_FORMAT)
|
149
149
|
fields_to_log[LEVEL] = SEVERITY_NAMES_MAP[severity]
|
150
150
|
|
151
|
-
@iodevice.write(Oj.dump(fields_to_log) << "\n")
|
151
|
+
@iodevice.write(Oj.dump(fields_to_log, mode: :compat, cache_keys: true, cache_str: 5) << "\n")
|
152
152
|
end
|
153
153
|
end
|
154
154
|
end
|
@@ -28,7 +28,7 @@ module Lorekeeper
|
|
28
28
|
# \e[colorm sets a color \e[0m resets all properties
|
29
29
|
def log_data(severity, message)
|
30
30
|
color = SEVERITY_TO_COLOR_MAP[severity]
|
31
|
-
@iodevice.write("\e[#{color}m#{message}\e[0m\n")
|
31
|
+
@iodevice.write("\e[#{color}m#{message.gsub('\n', "\n").gsub('\t', "\t")}\e[0m\n")
|
32
32
|
end
|
33
33
|
|
34
34
|
def inspect
|
@@ -43,16 +43,31 @@ module Lorekeeper
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
# To not raise NoMethodError for the methods defined in JSONLogger
|
47
|
+
def current_fields(*); end
|
48
|
+
def state(*); end
|
49
|
+
def add_thread_unsafe_fields(*); end
|
50
|
+
def remove_thread_unsafe_fields(*); end
|
51
|
+
def add_fields(*); end
|
52
|
+
def remove_fields(*); end
|
53
|
+
|
54
|
+
def exception(exception, custom_message = nil, custom_data = nil, custom_level = :error,
|
55
|
+
message: nil, data: nil, level: nil)
|
56
|
+
|
57
|
+
param_level = level || custom_level
|
58
|
+
param_data = data || custom_data
|
59
|
+
param_message = message || custom_message
|
60
|
+
|
61
|
+
log_level = METHOD_SEVERITY_MAP[param_level] || ERROR
|
48
62
|
|
49
63
|
if exception.is_a?(Exception)
|
50
|
-
|
51
|
-
|
52
|
-
|
64
|
+
message = param_message || exception.message
|
65
|
+
backtrace = "\n\nstack:\n#{exception.backtrace.join("\n")}" if exception.backtrace
|
66
|
+
data = "\n\ndata:\n#{param_data}" if param_data
|
67
|
+
log_data(log_level, "#{exception.class}: #{exception.message}; #{message} #{backtrace} #{data}")
|
53
68
|
else
|
54
69
|
log_data(METHOD_SEVERITY_MAP[:warn], 'Logger exception called without exception class.')
|
55
|
-
error_with_data("#{exception.class}: #{exception.inspect} #{
|
70
|
+
error_with_data("#{exception.class}: #{exception.inspect} #{param_message}", param_data)
|
56
71
|
end
|
57
72
|
end
|
58
73
|
end
|
data/lib/lorekeeper/version.rb
CHANGED
data/lorekeeper.gemspec
CHANGED
@@ -20,9 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
|
-
spec.required_ruby_version = '>= 2.
|
23
|
+
spec.required_ruby_version = '>= 2.5.0'
|
24
24
|
|
25
|
-
spec.add_dependency 'oj', '>= 3.
|
25
|
+
spec.add_dependency 'oj', '>= 3.12', '< 4.0'
|
26
26
|
|
27
27
|
spec.add_development_dependency 'activesupport', '>= 4.0'
|
28
28
|
spec.add_development_dependency 'bundler', '>= 1.16', '< 3.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lorekeeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordi Polo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.12'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '4.0'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '3.
|
29
|
+
version: '3.12'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '4.0'
|
@@ -183,10 +183,10 @@ executables: []
|
|
183
183
|
extensions: []
|
184
184
|
extra_rdoc_files: []
|
185
185
|
files:
|
186
|
+
- ".github/workflows/build.yml"
|
186
187
|
- ".gitignore"
|
187
188
|
- ".rspec"
|
188
189
|
- ".rubocop.yml"
|
189
|
-
- ".travis.yml"
|
190
190
|
- CHANGELOG.md
|
191
191
|
- Gemfile
|
192
192
|
- LICENSE.txt
|
@@ -213,7 +213,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
213
213
|
requirements:
|
214
214
|
- - ">="
|
215
215
|
- !ruby/object:Gem::Version
|
216
|
-
version: 2.
|
216
|
+
version: 2.5.0
|
217
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
218
218
|
requirements:
|
219
219
|
- - ">="
|