contextual_logger 1.3.0.dg.pre.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/contextual_logger/redactor.rb +2 -0
- data/lib/contextual_logger/version.rb +1 -1
- data/lib/contextual_logger.rb +12 -32
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a1e7646d07dccdd7cc32b76e5fc208741b8e9159a3ecbafe358bbe4e108d146
|
4
|
+
data.tar.gz: 52a2c52248c74fb8f9da1ce9fb13f1d8eca51f54b33356237825831b86a03881
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ba3b1504ba17953998665cfac2c04c14f0add53d901bebc1ca34f89c4f9e8076f15c8d24ba8eeb61d6fedd9fe9658d664c373911f35565cc70c806c6b3c4156
|
7
|
+
data.tar.gz: 771842eec3b0665fbea0ecded92cba37758d8d55d38350959dbf9e7b3b6f5c38225a37cc44b98aaaef6678842d7727191dbbe84106231737b67cd7bbbbcf8a56
|
data/lib/contextual_logger.rb
CHANGED
@@ -19,9 +19,6 @@ module ContextualLogger
|
|
19
19
|
unknown: Logger::Severity::UNKNOWN
|
20
20
|
}.freeze
|
21
21
|
|
22
|
-
class LambdaAlreadyDefinedError < StandardError
|
23
|
-
end
|
24
|
-
|
25
22
|
class << self
|
26
23
|
def new(logger)
|
27
24
|
logger.extend(LoggerMixin)
|
@@ -54,32 +51,12 @@ module ContextualLogger
|
|
54
51
|
module LoggerMixin
|
55
52
|
include Context
|
56
53
|
|
57
|
-
delegate :register_secret, :register_secret_regex, to: :redactor
|
54
|
+
delegate :register_secret, :register_secret_regex, :redact, to: :redactor
|
58
55
|
|
59
56
|
def global_context
|
60
57
|
@global_context ||= Context::EMPTY_CONTEXT
|
61
58
|
end
|
62
59
|
|
63
|
-
def add_global_context_lambda(field, lambda)
|
64
|
-
if field.blank?
|
65
|
-
raise ArgumentError, "The field cannot be empty"
|
66
|
-
end
|
67
|
-
|
68
|
-
unless lambda.respond_to?(:call)
|
69
|
-
raise ArgumentError, "A lambda must respond to the :call method"
|
70
|
-
end
|
71
|
-
|
72
|
-
if global_context_lambdas[field]
|
73
|
-
raise ::ContextualLogger::LambdaAlreadyDefinedError, "A lambda for `#{field}` is already defined"
|
74
|
-
end
|
75
|
-
|
76
|
-
@global_context_lambdas[field] = lambda
|
77
|
-
end
|
78
|
-
|
79
|
-
def global_context_lambdas
|
80
|
-
@global_context_lambdas ||= {}
|
81
|
-
end
|
82
|
-
|
83
60
|
def global_context=(context)
|
84
61
|
if (global_context_lock_message = ::ContextualLogger.global_context_lock_message)
|
85
62
|
raise ::ContextualLogger::GlobalContextIsLocked, global_context_lock_message
|
@@ -159,8 +136,7 @@ module ContextualLogger
|
|
159
136
|
message = arg1
|
160
137
|
progname = arg2 || @progname
|
161
138
|
end
|
162
|
-
|
163
|
-
write_entry_to_log(severity, Time.now, progname, message, context: full_context)
|
139
|
+
write_entry_to_log(severity, Time.now, progname, message, context: deep_merge_with_current_context(context))
|
164
140
|
end
|
165
141
|
|
166
142
|
true
|
@@ -209,13 +185,17 @@ module ContextualLogger
|
|
209
185
|
current_context
|
210
186
|
end
|
211
187
|
end
|
188
|
+
end
|
212
189
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
190
|
+
module BroadcastLoggerMixin
|
191
|
+
method_names = LOG_LEVEL_NAMES_TO_SEVERITY.keys << :add
|
192
|
+
|
193
|
+
method_names.each do |method_name|
|
194
|
+
class_eval(<<~EOS, __FILE__, __LINE__ + 1)
|
195
|
+
def #{method_name}(...)
|
196
|
+
dispatch { |logger| logger.#{method_name}(...) }
|
197
|
+
end
|
198
|
+
EOS
|
219
199
|
end
|
220
200
|
end
|
221
201
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contextual_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Ebentier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '6.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '6.0'
|
41
41
|
description: A way to add context to the logs you have
|
42
42
|
email: jebentier@invoca.com
|
43
43
|
executables: []
|
@@ -69,11 +69,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
69
|
version: '0'
|
70
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- - "
|
72
|
+
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
74
|
+
version: '0'
|
75
75
|
requirements: []
|
76
|
-
rubygems_version: 3.
|
76
|
+
rubygems_version: 3.3.27
|
77
77
|
signing_key:
|
78
78
|
specification_version: 4
|
79
79
|
summary: Add context to your logger
|