lorekeeper 2.3.2 → 2.4.0

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: 53332589726c07831fc34d3d63b7517de62fd1a75c11d1cbf772b6088d125eed
4
- data.tar.gz: 797d799f0268b110fe584ead9bdb9f9c3f779bca7d1e8d0fb75c796409a340c5
3
+ metadata.gz: 8099634bb3a3f3d4d348737b0c9634a3a70743c1d868ebec42c194865df7a13c
4
+ data.tar.gz: c216efb9f7f6c2e06c357aee59d1f0ad8299445c5becc0d8fc4f2d444e5193ec
5
5
  SHA512:
6
- metadata.gz: c773417845d13a54058bd01b1541a64fa9564bce845fec21efcd69fa23916a323da0c679d86e8950c7c7dea1fa7c4a18e02429f21b4d896c670d4bb952ade48e
7
- data.tar.gz: f95030ee5fe64f4cecd0cd9b15217897324bf2ac6aca1daed1a20a8daea233c029412a6a021dddd8bcd7d75d94aee673aa531f35bc8a214b6c07a0e666fca377
6
+ metadata.gz: 93af9f7d3142bdc8166a14e2324b71fe3e51c3f150ea2fccee8557fc2d17b92517b3d6214e8021ed86bdbf632bed836b12027bf438f4bba0099ef1bbaed32e63
7
+ data.tar.gz: d81128b6905c1f70e7946bf7be63bf35923d40056d9c9ab7274397b7ff8726da582109f83c0c2905768c0c694ac48c2fa8574dd894f10a0b60d6c3b0ac28dfbb
@@ -14,7 +14,7 @@ jobs:
14
14
  runs-on: ubuntu-latest
15
15
  strategy:
16
16
  matrix:
17
- ruby-version: ['2.7', '3.0', '3.1']
17
+ ruby-version: ['2.7', '3.0', '3.1', '3.2']
18
18
 
19
19
  steps:
20
20
  - uses: actions/checkout@v2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 2.4.0
2
+ * Add `#with_level` method support added to the stdlib's Logger in [#85](https://github.com/ruby/logger/issues/85)
3
+ * Support symbol log level setting
4
+
1
5
  # 2.3.2
2
6
  * Ensure additional fields are reset after logging
3
7
  * Let Oj fallback to :object mode for non-representable data
data/Rakefile CHANGED
@@ -28,7 +28,7 @@ end
28
28
 
29
29
  def create_simple_logger
30
30
  logfile = Tempfile.new('my_test_log.log')
31
- ::Logger.new(logfile.path)
31
+ Logger.new(logfile.path)
32
32
  end
33
33
 
34
34
  # This task is used to help development of Lorekeeper. Use together with rbtrace
data/bin/console CHANGED
File without changes
data/bin/setup CHANGED
File without changes
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'logger'
4
+ require 'fiber'
4
5
 
5
6
  module Lorekeeper
6
7
  # Very simple, very fast logger
7
8
  class FastLogger
8
9
  include ::Logger::Severity # contains the levels constants: DEBUG, ERROR, etc.
9
- attr_accessor :level, # Current level, default: DEBUG
10
- :formatter # Just for compatibility with Logger, not used
10
+ attr_accessor :formatter # Just for compatibility with Logger, not used
11
11
 
12
12
  def debug?; level <= DEBUG; end
13
13
  def info?; level <= INFO; end
@@ -19,6 +19,29 @@ module Lorekeeper
19
19
  @level = DEBUG
20
20
  @iodevice = LogDevice.new(file)
21
21
  @file = file # We only keep this so we can inspect where we are sending the logs
22
+ @level_override = {}
23
+ end
24
+
25
+ def level
26
+ @level_override[Fiber.current] || @level
27
+ end
28
+
29
+ def level=(severity)
30
+ @level = coerce(severity)
31
+ end
32
+
33
+ def with_level(severity)
34
+ prev = level
35
+ @level_override[Fiber.current] = coerce(severity)
36
+ begin
37
+ yield
38
+ ensure
39
+ if prev
40
+ @level_override[Fiber.current] = prev
41
+ else
42
+ @level_override.delete(Fiber.current)
43
+ end
44
+ end
22
45
  end
23
46
 
24
47
  LOGGING_METHODS = %i[
@@ -55,7 +78,7 @@ module Lorekeeper
55
78
 
56
79
  # This is part of the standard Logger API, we need this to be compatible
57
80
  def add(severity, message_param = nil, progname = nil, &block)
58
- return true if severity < @level
81
+ return true if severity < level
59
82
 
60
83
  message = block&.call || message_param || progname
61
84
  log_data(severity, message.freeze)
@@ -83,6 +106,12 @@ module Lorekeeper
83
106
  @iodevice.write(message)
84
107
  end
85
108
 
109
+ def coerce(severity)
110
+ return severity if severity.is_a?(Integer)
111
+
112
+ METHOD_SEVERITY_MAP[severity] || raise(ArgumentError, "invalid log level: #{severity}")
113
+ end
114
+
86
115
  require 'monitor'
87
116
  # Mutex to avoid broken lines when multiple threads access the log file
88
117
  class LogDeviceMutex
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lorekeeper
4
- VERSION = '2.3.2'
4
+ VERSION = '2.4.0'
5
5
  end
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: 2.3.2
4
+ version: 2.4.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: 2022-08-23 00:00:00.000000000 Z
11
+ date: 2023-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -233,7 +233,7 @@ homepage: https://github.com/JordiPolo/lorekeeper
233
233
  licenses:
234
234
  - MIT
235
235
  metadata: {}
236
- post_install_message:
236
+ post_install_message:
237
237
  rdoc_options: []
238
238
  require_paths:
239
239
  - lib
@@ -248,8 +248,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
248
  - !ruby/object:Gem::Version
249
249
  version: '0'
250
250
  requirements: []
251
- rubygems_version: 3.2.15
252
- signing_key:
251
+ rubygems_version: 3.0.3.1
252
+ signing_key:
253
253
  specification_version: 4
254
254
  summary: Very fast JSON logger
255
255
  test_files: []