lorekeeper 1.9.0 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/build.yml +29 -0
- data/CHANGELOG.md +13 -0
- data/README.md +18 -4
- data/lib/lorekeeper/fast_logger.rb +7 -2
- data/lib/lorekeeper/json_logger.rb +14 -5
- data/lib/lorekeeper/version.rb +1 -1
- data/lorekeeper.gemspec +2 -1
- metadata +22 -9
- data/.travis.yml +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: db3ae6a493b8fc903122557d5144db57633e3c72a881cb4bc88ad458d438f7dc
|
4
|
+
data.tar.gz: 69ba8f5fd5ea48d6325f27ae777c91e857e28c5f7e6093cef71aa427cfcb8266
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b3b703f5182598b73f0c86411b9a627060eed1e0c59ddd1b9507dd3e9f28b5c3239e2e48a59bdf42edc017fa5df1acb4ba8aee5f502f73f21ff6fcc1876c8b4
|
7
|
+
data.tar.gz: 8925f11071fbccff8ddca89066a473b9286c8aedd87f9b76c3f872388e83ead883f2b78fe3645e71753009535f9e7b2e09e0e3921b4f64883a86f49c3737da72
|
@@ -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']
|
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,16 @@
|
|
1
|
+
# 1.12.0
|
2
|
+
* Remove ZipkinTracer information from stacktrace output
|
3
|
+
* Move CI to GitHub Actions
|
4
|
+
|
5
|
+
# 1.11.1
|
6
|
+
* Modify FastLogger#add to log progname as a message if no message and block are given
|
7
|
+
|
8
|
+
# 1.11.0
|
9
|
+
* Support for activerecord-session_store v2 which calls only silence and not silence_logger
|
10
|
+
|
11
|
+
# 1.10.0
|
12
|
+
* Use ActiveSupport::BacktraceCleaner to reduce noise in stacktrace output
|
13
|
+
|
1
14
|
# 1.9.0
|
2
15
|
* Remove Newrelic instrumentation information from stacktrace output
|
3
16
|
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Lorekeeper
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![build](https://github.com/JordiPolo/lorekeeper/actions/workflows/build.yml/badge.svg)](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
|
@@ -54,9 +54,9 @@ module Lorekeeper
|
|
54
54
|
end
|
55
55
|
|
56
56
|
# This is part of the standard Logger API, we need this to be compatible
|
57
|
-
def add(severity, message_param = nil,
|
57
|
+
def add(severity, message_param = nil, progname = nil, &block)
|
58
58
|
return true if severity < @level
|
59
|
-
message = message_param || (block && block.call)
|
59
|
+
message = message_param || (block && block.call) || progname
|
60
60
|
log_data(severity, message.freeze)
|
61
61
|
end
|
62
62
|
|
@@ -68,6 +68,11 @@ module Lorekeeper
|
|
68
68
|
yield if block_given?
|
69
69
|
end
|
70
70
|
|
71
|
+
# activerecord-session_store v2 is now simply calling silence instead of silence_logger
|
72
|
+
def silence(&block)
|
73
|
+
yield if block_given?
|
74
|
+
end
|
75
|
+
|
71
76
|
# inherited classes probably want to reimplement this
|
72
77
|
def log_data(_severity, message)
|
73
78
|
@iodevice.write(message)
|
@@ -9,6 +9,7 @@ module Lorekeeper
|
|
9
9
|
def initialize(file)
|
10
10
|
reset_state
|
11
11
|
@base_fields = { MESSAGE => '', TIMESTAMP => '', LEVEL => '' }
|
12
|
+
@backtrace_cleaner = set_backtrace_cleaner
|
12
13
|
super(file)
|
13
14
|
end
|
14
15
|
|
@@ -97,11 +98,19 @@ module Lorekeeper
|
|
97
98
|
|
98
99
|
# Some instrumentation libraries pollute the stacktrace and create a large output which may
|
99
100
|
# cause problems with certain logging backends.
|
100
|
-
#
|
101
|
+
# Hardcording newrelic, active_support/callbacks and zipkin-tracer now here.
|
102
|
+
# In the future if this list grows, we may make it configurable.
|
101
103
|
def clean_backtrace(backtrace)
|
102
|
-
backtrace
|
103
|
-
|
104
|
-
|
104
|
+
@backtrace_cleaner&.clean(backtrace) || backtrace
|
105
|
+
end
|
106
|
+
|
107
|
+
def set_backtrace_cleaner
|
108
|
+
return nil unless defined?(ActiveSupport::BacktraceCleaner)
|
109
|
+
|
110
|
+
cleaner = ActiveSupport::BacktraceCleaner.new
|
111
|
+
cleaner.remove_silencers!
|
112
|
+
cleaner.add_silencer { |line| line.match?(BLACKLISTED_FINGERPRINT) }
|
113
|
+
cleaner
|
105
114
|
end
|
106
115
|
|
107
116
|
THREAD_KEY = 'lorekeeper_jsonlogger_key' # Shared by all threads but unique by thread
|
@@ -112,7 +121,7 @@ module Lorekeeper
|
|
112
121
|
EXCEPTION = 'exception'
|
113
122
|
STACK = 'stack'
|
114
123
|
DATA = 'data'
|
115
|
-
BLACKLISTED_FINGERPRINT =
|
124
|
+
BLACKLISTED_FINGERPRINT = %r{newrelic_rpm|active_support/callbacks.rb|zipkin-tracer}.freeze
|
116
125
|
|
117
126
|
def with_extra_fields(fields)
|
118
127
|
state[:extra_fields] = fields
|
data/lib/lorekeeper/version.rb
CHANGED
data/lorekeeper.gemspec
CHANGED
@@ -20,10 +20,11 @@ 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.4.0'
|
24
24
|
|
25
25
|
spec.add_dependency 'oj', '>= 3.4', '< 4.0'
|
26
26
|
|
27
|
+
spec.add_development_dependency 'activesupport', '>= 4.0'
|
27
28
|
spec.add_development_dependency 'bundler', '>= 1.16', '< 3.0'
|
28
29
|
spec.add_development_dependency 'rake', '~> 12.0'
|
29
30
|
spec.add_development_dependency 'rspec', '~> 3.8'
|
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: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordi Polo
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -30,6 +30,20 @@ dependencies:
|
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '4.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: activesupport
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '4.0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '4.0'
|
33
47
|
- !ruby/object:Gem::Dependency
|
34
48
|
name: bundler
|
35
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -169,10 +183,10 @@ executables: []
|
|
169
183
|
extensions: []
|
170
184
|
extra_rdoc_files: []
|
171
185
|
files:
|
186
|
+
- ".github/workflows/build.yml"
|
172
187
|
- ".gitignore"
|
173
188
|
- ".rspec"
|
174
189
|
- ".rubocop.yml"
|
175
|
-
- ".travis.yml"
|
176
190
|
- CHANGELOG.md
|
177
191
|
- Gemfile
|
178
192
|
- LICENSE.txt
|
@@ -191,7 +205,7 @@ homepage: https://github.com/JordiPolo/lorekeeper
|
|
191
205
|
licenses:
|
192
206
|
- MIT
|
193
207
|
metadata: {}
|
194
|
-
post_install_message:
|
208
|
+
post_install_message:
|
195
209
|
rdoc_options: []
|
196
210
|
require_paths:
|
197
211
|
- lib
|
@@ -199,16 +213,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
199
213
|
requirements:
|
200
214
|
- - ">="
|
201
215
|
- !ruby/object:Gem::Version
|
202
|
-
version: 2.
|
216
|
+
version: 2.4.0
|
203
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
218
|
requirements:
|
205
219
|
- - ">="
|
206
220
|
- !ruby/object:Gem::Version
|
207
221
|
version: '0'
|
208
222
|
requirements: []
|
209
|
-
|
210
|
-
|
211
|
-
signing_key:
|
223
|
+
rubygems_version: 3.2.15
|
224
|
+
signing_key:
|
212
225
|
specification_version: 4
|
213
226
|
summary: Very fast JSON logger
|
214
227
|
test_files: []
|
data/.travis.yml
DELETED