twiglet 3.9.2 → 3.10.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/lib/hash_extensions.rb +1 -1
- data/lib/twiglet/logger.rb +7 -1
- data/lib/twiglet/message.rb +1 -1
- data/lib/twiglet/version.rb +1 -1
- data/test/logger_test.rb +23 -2
- data/twiglet.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6362109470f346c6703ed9e13e82904195f201cac31e1edf1dad8714c4312d79
|
4
|
+
data.tar.gz: a06b359e837cf995f78efdab94c53e5017ccc4ca6d06373a05148f0e4b93621c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd56a05ee8a42910901a85de11940ea16b1e6a4578fd2501aeb4e794674561dd9594bb10fedc0b07c207df5823c44361cf1a72d753b241fe4e564e786464f459
|
7
|
+
data.tar.gz: 7fa75694d0ff55caa28df71703fd4e8c14e00185149c456b26c8030315519e0caafcc77e0e10efe1d04aae1093dd53c9f1b4462b97f04d8352c996241a271662
|
data/lib/hash_extensions.rb
CHANGED
data/lib/twiglet/logger.rb
CHANGED
@@ -82,9 +82,15 @@ module Twiglet
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def context_provider(&blk)
|
85
|
+
new_context_provider = blk
|
86
|
+
if @args[:context_provider]
|
87
|
+
new_context_provider = lambda do
|
88
|
+
@args[:context_provider].call.merge(blk.call)
|
89
|
+
end
|
90
|
+
end
|
85
91
|
self.class.new(
|
86
92
|
@service_name,
|
87
|
-
**@args.merge(context_provider:
|
93
|
+
**@args.merge(context_provider: new_context_provider)
|
88
94
|
)
|
89
95
|
end
|
90
96
|
|
data/lib/twiglet/message.rb
CHANGED
data/lib/twiglet/version.rb
CHANGED
data/test/logger_test.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'minitest/autorun'
|
4
4
|
require 'minitest/mock'
|
5
5
|
require_relative '../lib/twiglet/logger'
|
6
|
+
require 'active_support'
|
6
7
|
|
7
8
|
LEVELS = [
|
8
9
|
{ method: :debug, level: 'debug' },
|
@@ -266,6 +267,27 @@ describe Twiglet::Logger do
|
|
266
267
|
assert_equal 'my-context-id', log[:context][:id]
|
267
268
|
end
|
268
269
|
|
270
|
+
it "previously supplied context providers should be preserved" do
|
271
|
+
# Let's add some context to this customer journey
|
272
|
+
purchase_logger = @logger
|
273
|
+
.context_provider { { 'first-context' => { 'first-id' => 'my-first-context-id' } } }
|
274
|
+
.context_provider { { 'second-context' => { 'second-id' => 'my-second-context-id' } } }
|
275
|
+
# do stuff
|
276
|
+
purchase_logger.info(
|
277
|
+
{
|
278
|
+
message: 'customer bought a dog',
|
279
|
+
pet: { name: 'Barker', species: 'dog', breed: 'Bitsa' }
|
280
|
+
}
|
281
|
+
)
|
282
|
+
|
283
|
+
log = read_json @buffer
|
284
|
+
|
285
|
+
assert_equal 'customer bought a dog', log[:message]
|
286
|
+
assert_equal 'Barker', log[:pet][:name]
|
287
|
+
assert_equal 'my-first-context-id', log[:'first-context'][:'first-id']
|
288
|
+
assert_equal 'my-second-context-id', log[:'second-context'][:'second-id']
|
289
|
+
end
|
290
|
+
|
269
291
|
it "should log 'message' string property" do
|
270
292
|
message = {}
|
271
293
|
message['message'] = 'Guinea pigs arrived'
|
@@ -393,8 +415,7 @@ describe Twiglet::Logger do
|
|
393
415
|
assert_equal 'Some error', actual_log[:message]
|
394
416
|
end
|
395
417
|
|
396
|
-
it 'should log error type properly even when active_support
|
397
|
-
require 'active_support/json'
|
418
|
+
it 'should log error type properly even when active_support is required' do
|
398
419
|
e = StandardError.new('Unknown error')
|
399
420
|
@logger.error('Artificially raised exception with string message', e)
|
400
421
|
|
data/twiglet.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
|
|
21
21
|
|
22
22
|
gem.license = 'Copyright SimplyBusiness'
|
23
23
|
|
24
|
-
gem.
|
24
|
+
gem.add_dependency 'json-schema'
|
25
25
|
gem.add_development_dependency 'minitest'
|
26
26
|
gem.add_development_dependency 'rake'
|
27
27
|
gem.add_development_dependency 'simplecov', '0.17.1'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twiglet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simply Business
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-schema
|