logster 2.11.1 → 2.11.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: 32c3d946dbbe5f1d0f1869aa4e262cf40ec1b0edeca76f8fbc6ce22e827140cc
4
- data.tar.gz: 15af1b43a8afe443c83729a680c09ae43a00d626b174dbd9bb2413bcdbd3fe97
3
+ metadata.gz: ac4fd2b906013693d1b76679876762a938c333642df5306c0e1c7b1e53c01e04
4
+ data.tar.gz: a6980fcc69d06ce88f821c83662400b5a17887a8896fd06df096a06c7cffa40f
5
5
  SHA512:
6
- metadata.gz: 71dc344fa89d6731db40a03b56def3fc205d0c522894cc47cc90c7443cb21026cfcdf0b1bf80abb390ada08ed3c6d90b8a6f94c2a8a67dfc00db720a59d04169
7
- data.tar.gz: ab4ce89f0ea3d096c0891504a11d7a387c3e6c86bd2ad3b4fdffd4ab29d55d1b4043f8f7542ec197dfeac1a9eaeab8c913c63988a3b8601cbc88ceb214781d87
6
+ metadata.gz: ea5f6d1da6046eb5cad955ac63b435ed98597769bf8da58c6fccac41ab48d4fb6bb06f0b25b8b993224e9f1940a60b4deed2750b55072d5be3b84d6abfe64cc7
7
+ data.tar.gz: 98cecbb8c155368f57d70482e57be3e04ef780c06c8c983255aed44e09a78af176bbe375f78b685788e6cf6c9748be51ff521a00d11075004bdedc424fe535a8
data/CHANGELOG.md CHANGED
@@ -1,4 +1,7 @@
1
1
  # CHANGELOG
2
+ - 2022-04-28: 2.11.2
3
+
4
+ - FIX: store override level in thread local storage (Truffle Ruby compatability)
2
5
 
3
6
  - 2022-04-21: 2.11.1
4
7
 
@@ -4,7 +4,7 @@ require 'logger'
4
4
 
5
5
  module Logster
6
6
  class Logger < ::Logger
7
- LOGSTER_ENV = "logster_env".freeze
7
+ LOGSTER_ENV = "logster_env"
8
8
 
9
9
  attr_accessor :store, :skip_store
10
10
  attr_reader :chained
@@ -12,21 +12,17 @@ module Logster
12
12
  def initialize(store)
13
13
  super(nil)
14
14
  @store = store
15
- @override_levels = nil
16
15
  @chained = []
17
16
  @skip_store = false
17
+ @logster_override_level_key = "logster_override_level_#{object_id}"
18
18
  end
19
19
 
20
20
  def override_level=(val)
21
- tid = Thread.current.object_id
22
-
23
- ol = @override_levels
24
- if val.nil? && ol && ol.key?(tid)
25
- ol.delete(tid)
26
- @override_levels = nil if ol.length == 0
27
- elsif val
28
- (@override_levels ||= {})[tid] = val
29
- end
21
+ Thread.current[@logster_override_level_key] = val
22
+ end
23
+
24
+ def override_level
25
+ Thread.current[@logster_override_level_key]
30
26
  end
31
27
 
32
28
  def chain(logger)
@@ -55,8 +51,7 @@ module Logster
55
51
  end
56
52
 
57
53
  def level
58
- ol = @override_levels
59
- (ol && ol[Thread.current.object_id]) || @level
54
+ Thread.current[@logster_override_level_key] || @level
60
55
  end
61
56
 
62
57
  def add_with_opts(severity, message = nil, progname = progname(), opts = nil, &block)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Logster
4
- VERSION = "2.11.1"
4
+ VERSION = "2.11.2"
5
5
  end
@@ -26,6 +26,12 @@ class TestLogger < Minitest::Test
26
26
  end
27
27
 
28
28
  def test_per_thread_override
29
+ logger2 = Logster::Logger.new(@store)
30
+ logger2.override_level = 2
31
+
32
+ # we should not leak between objects
33
+ assert_nil @logger.override_level
34
+
29
35
  @logger.override_level = 2
30
36
 
31
37
  @logger.add(0, "test", "prog", backtrace: "backtrace", env: { a: "x" })
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logster
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.1
4
+ version: 2.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-25 00:00:00.000000000 Z
11
+ date: 2022-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler