betterlog 2.0.0 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41bb65aafa33ccbe83390a1d8a4a68a98f9a88ff94c50de62b71afe32f81fac2
4
- data.tar.gz: e4c9c13fdb23f7448744ef34dfd6667cb1ce8de6a6e8dda6017ccbf874d19fd2
3
+ metadata.gz: c916f2cfc831f6a3ca23ab03b861dacb4f9e48af67a67f336e2bd9a2aa7412f6
4
+ data.tar.gz: faa732b45a4e18bdcd143073bf991c57490b64cd38402e3a90bfc1c908ed8aa3
5
5
  SHA512:
6
- metadata.gz: 55b3b6f9ac7ed4d641902c798cb6c372c082302c2a3a8b93373b333055168e7647f90229c285a287b886d5f90d8cd09ef4c49fefa268e720cd25b3f6590a902b
7
- data.tar.gz: 96415752787e2ac1e3345bdfa448fdb6f752dad4d338d0ef940473c7596c167635ea9e5660ef7d8313af3a1201ae2efd21a80a92eb6838f25cbaa37e1051853d
6
+ metadata.gz: 0cd114b7cbd2a74cb45475f92b4066c819a8430f68faa18096f0fe155d1fb8792901925489df3c0550c29e38a84b69068df3f08f52c3095ff2397ccc116fe65c
7
+ data.tar.gz: caab1d2b2522e794ea9a419c7cd6a643fdd1bbb76c7b2c696c0b94910da475aa839098fb58a5e752fb0f27a5b2e7b8db1e3660ee0bef8b32ff3f2c60473b9f42
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.0.2
data/betterlog.gemspec CHANGED
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: betterlog 2.0.0 ruby lib
2
+ # stub: betterlog 2.0.2 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "betterlog".freeze
6
- s.version = "2.0.0"
6
+ s.version = "2.0.2".freeze
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["betterplace Developers".freeze]
11
- s.date = "2023-08-17"
11
+ s.date = "2024-01-25"
12
12
  s.description = "This library provides structure json logging for our rails projects".freeze
13
13
  s.email = "developers@betterplace.org".freeze
14
14
  s.executables = ["betterlog".freeze]
@@ -16,41 +16,23 @@ Gem::Specification.new do |s|
16
16
  s.files = [".all_images.yml".freeze, ".github/workflows/codeql-analysis.yml".freeze, ".gitignore".freeze, ".semaphore/semaphore.yml".freeze, ".tool-versions".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "betterlog.gemspec".freeze, "bin/betterlog".freeze, "config/log.yml".freeze, "lib/betterlog.rb".freeze, "lib/betterlog/global_metadata.rb".freeze, "lib/betterlog/log.rb".freeze, "lib/betterlog/log/event.rb".freeze, "lib/betterlog/log/event_formatter.rb".freeze, "lib/betterlog/log/severity.rb".freeze, "lib/betterlog/log_event_formatter.rb".freeze, "lib/betterlog/notifiers.rb".freeze, "lib/betterlog/railtie.rb".freeze, "lib/betterlog/version.rb".freeze, "spec/betterlog/global_metadata_spec.rb".freeze, "spec/betterlog/log/event_spec.rb".freeze, "spec/betterlog/log/severity_spec.rb".freeze, "spec/betterlog/log_event_formatter_spec.rb".freeze, "spec/betterlog/log_spec.rb".freeze, "spec/betterlog/version_spec.rb".freeze, "spec/spec_helper.rb".freeze]
17
17
  s.homepage = "http://github.com/betterplace/betterlog".freeze
18
18
  s.rdoc_options = ["--title".freeze, "Betterlog".freeze, "--main".freeze, "README.md".freeze]
19
- s.rubygems_version = "3.3.26".freeze
19
+ s.rubygems_version = "3.5.5".freeze
20
20
  s.summary = "Structured logging support for bp".freeze
21
21
  s.test_files = ["spec/betterlog/global_metadata_spec.rb".freeze, "spec/betterlog/log/event_spec.rb".freeze, "spec/betterlog/log/severity_spec.rb".freeze, "spec/betterlog/log_event_formatter_spec.rb".freeze, "spec/betterlog/log_spec.rb".freeze, "spec/betterlog/version_spec.rb".freeze, "spec/spec_helper.rb".freeze]
22
22
 
23
- if s.respond_to? :specification_version then
24
- s.specification_version = 4
25
- end
23
+ s.specification_version = 4
26
24
 
27
- if s.respond_to? :add_runtime_dependency then
28
- s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.12.0"])
29
- s.add_development_dependency(%q<rake>.freeze, [">= 0"])
30
- s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
31
- s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
32
- s.add_development_dependency(%q<debug>.freeze, [">= 0"])
33
- s.add_development_dependency(%q<all_images>.freeze, [">= 0"])
34
- s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.3", ">= 1.22.0"])
35
- s.add_runtime_dependency(%q<complex_config>.freeze, [">= 0"])
36
- s.add_runtime_dependency(%q<file-tail>.freeze, ["~> 1.0"])
37
- s.add_runtime_dependency(%q<json>.freeze, ["~> 2.0"])
38
- s.add_runtime_dependency(%q<term-ansicolor>.freeze, ["~> 1.3"])
39
- s.add_runtime_dependency(%q<redlock>.freeze, [">= 0"])
40
- s.add_runtime_dependency(%q<excon>.freeze, [">= 0"])
41
- else
42
- s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.12.0"])
43
- s.add_dependency(%q<rake>.freeze, [">= 0"])
44
- s.add_dependency(%q<rspec>.freeze, [">= 0"])
45
- s.add_dependency(%q<simplecov>.freeze, [">= 0"])
46
- s.add_dependency(%q<debug>.freeze, [">= 0"])
47
- s.add_dependency(%q<all_images>.freeze, [">= 0"])
48
- s.add_dependency(%q<tins>.freeze, ["~> 1.3", ">= 1.22.0"])
49
- s.add_dependency(%q<complex_config>.freeze, [">= 0"])
50
- s.add_dependency(%q<file-tail>.freeze, ["~> 1.0"])
51
- s.add_dependency(%q<json>.freeze, ["~> 2.0"])
52
- s.add_dependency(%q<term-ansicolor>.freeze, ["~> 1.3"])
53
- s.add_dependency(%q<redlock>.freeze, [">= 0"])
54
- s.add_dependency(%q<excon>.freeze, [">= 0"])
55
- end
25
+ s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.12.0".freeze])
26
+ s.add_development_dependency(%q<rake>.freeze, [">= 0".freeze])
27
+ s.add_development_dependency(%q<rspec>.freeze, [">= 0".freeze])
28
+ s.add_development_dependency(%q<simplecov>.freeze, [">= 0".freeze])
29
+ s.add_development_dependency(%q<debug>.freeze, [">= 0".freeze])
30
+ s.add_development_dependency(%q<all_images>.freeze, [">= 0".freeze])
31
+ s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.3".freeze, ">= 1.22.0".freeze])
32
+ s.add_runtime_dependency(%q<complex_config>.freeze, [">= 0".freeze])
33
+ s.add_runtime_dependency(%q<file-tail>.freeze, ["~> 1.0".freeze])
34
+ s.add_runtime_dependency(%q<json>.freeze, ["~> 2.0".freeze])
35
+ s.add_runtime_dependency(%q<term-ansicolor>.freeze, ["~> 1.3".freeze])
36
+ s.add_runtime_dependency(%q<redlock>.freeze, [">= 0".freeze])
37
+ s.add_runtime_dependency(%q<excon>.freeze, [">= 0".freeze])
56
38
  end
@@ -20,11 +20,15 @@ module Betterlog
20
20
  keys.each { current.delete(_1) }
21
21
  end
22
22
 
23
- def with_context(data = {})
23
+ def with_meta(data = {}, &block)
24
24
  add data
25
- yield current.dup.freeze
25
+ block.call
26
26
  ensure
27
27
  remove data
28
28
  end
29
29
  end
30
+
31
+ def self.with_meta(data = {}, &block)
32
+ Betterlog::GlobalMetadata.with_meta(data, &block)
33
+ end
30
34
  end
@@ -1,6 +1,6 @@
1
1
  module Betterlog
2
2
  # Betterlog version
3
- VERSION = '2.0.0'
3
+ VERSION = '2.0.2'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -33,38 +33,41 @@ describe Betterlog::GlobalMetadata do
33
33
  end
34
34
  end
35
35
 
36
- describe '.with_context' do
36
+ describe '.with_meta' do
37
37
  it 'can add to context and remove it' do
38
38
  expect(Betterlog::GlobalMetadata.current).to be_empty
39
- Betterlog::GlobalMetadata.with_context(
39
+ Betterlog::GlobalMetadata.with_meta(
40
40
  'foo' => 'bar',
41
41
  :bar => 'foo',
42
- ) do |my_context|
42
+ ) do
43
43
  expect(Betterlog::GlobalMetadata.current).to eq(foo: 'bar', bar: 'foo')
44
- expect(my_context).to eq(foo: 'bar', bar: 'foo')
45
- expect(my_context).to be_frozen
46
44
  end
47
45
  expect(Betterlog::GlobalMetadata.current).to be_empty
48
46
  end
49
47
 
50
48
  it 'can add to nested context and remove it' do
51
49
  expect(Betterlog::GlobalMetadata.current).to be_empty
52
- Betterlog::GlobalMetadata.with_context(
50
+ Betterlog::GlobalMetadata.with_meta(
53
51
  'foo' => 'bar',
54
52
  :bar => 'foo',
55
- ) do |my_context|
53
+ ) do
56
54
  expect(Betterlog::GlobalMetadata.current).to eq(foo: 'bar', bar: 'foo')
57
- expect(my_context).to eq(foo: 'bar', bar: 'foo')
58
- expect(my_context).to be_frozen
59
- Betterlog::GlobalMetadata.with_context('quux' => 'quark') do |my_context|
60
- expect(my_context).to be_frozen
55
+ Betterlog::GlobalMetadata.with_meta('quux' => 'quark') do |my_context|
61
56
  expect(Betterlog::GlobalMetadata.current).to eq(foo: 'bar', bar: 'foo', quux: 'quark')
62
- expect(my_context).to eq(foo: 'bar', bar: 'foo', quux: 'quark')
63
57
  end
64
- expect(my_context).to eq(foo: 'bar', bar: 'foo')
65
58
  end
66
59
  expect(Betterlog::GlobalMetadata.current).to be_empty
67
60
  end
61
+
62
+ it 'has shortcut method Betterlog.with_meta' do
63
+ expect(Betterlog::GlobalMetadata.current).to be_empty
64
+ Betterlog.with_meta(
65
+ 'foo' => 'bar',
66
+ :bar => 'foo',
67
+ ) do
68
+ expect(Betterlog::GlobalMetadata.current).to eq(foo: 'bar', bar: 'foo')
69
+ end
70
+ end
68
71
  end
69
72
 
70
73
  class FakeNotifierClass
@@ -115,7 +115,7 @@ describe Betterlog::Log do
115
115
  'test',
116
116
  hash_including(meta: { foo: 'bar' }),
117
117
  )
118
- Betterlog::GlobalMetadata.with_context(foo: 'bar') do
118
+ Betterlog.with_meta(foo: 'bar') do
119
119
  Log.info('test', notify: true)
120
120
  end
121
121
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: betterlog
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - betterplace Developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-17 00:00:00.000000000 Z
11
+ date: 2024-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar
@@ -268,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
268
  - !ruby/object:Gem::Version
269
269
  version: '0'
270
270
  requirements: []
271
- rubygems_version: 3.3.26
271
+ rubygems_version: 3.5.5
272
272
  signing_key:
273
273
  specification_version: 4
274
274
  summary: Structured logging support for bp