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 +4 -4
- data/.github/workflows/build.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/Rakefile +1 -1
- data/bin/console +0 -0
- data/bin/setup +0 -0
- data/lib/lorekeeper/fast_logger.rb +32 -3
- data/lib/lorekeeper/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8099634bb3a3f3d4d348737b0c9634a3a70743c1d868ebec42c194865df7a13c
|
4
|
+
data.tar.gz: c216efb9f7f6c2e06c357aee59d1f0ad8299445c5becc0d8fc4f2d444e5193ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93af9f7d3142bdc8166a14e2324b71fe3e51c3f150ea2fccee8557fc2d17b92517b3d6214e8021ed86bdbf632bed836b12027bf438f4bba0099ef1bbaed32e63
|
7
|
+
data.tar.gz: d81128b6905c1f70e7946bf7be63bf35923d40056d9c9ab7274397b7ff8726da582109f83c0c2905768c0c694ac48c2fa8574dd894f10a0b60d6c3b0ac28dfbb
|
data/.github/workflows/build.yml
CHANGED
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
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 :
|
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 <
|
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
|
data/lib/lorekeeper/version.rb
CHANGED
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.
|
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:
|
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.
|
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: []
|