dry-logger 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +55 -21
- data/LICENSE +2 -1
- data/README.md +7 -13
- data/dry-logger.gemspec +12 -6
- data/lib/dry/logger/constants.rb +1 -1
- data/lib/dry/logger/dispatcher.rb +47 -33
- data/lib/dry/logger/execution_context.rb +51 -0
- data/lib/dry/logger/filter.rb +9 -16
- data/lib/dry/logger/formatters/rack.rb +1 -1
- data/lib/dry/logger/formatters/string.rb +2 -4
- data/lib/dry/logger/formatters/template.rb +0 -1
- data/lib/dry/logger/version.rb +1 -1
- metadata +55 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8d27303efa558c60b1f0f9710b1c9419223d7b421c61b7f6efbea241b54ca486
|
|
4
|
+
data.tar.gz: ada0ee3f313045a3cfbcd26e15da7642741d6217efe3e834542935b5efbaa0b9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5c42481abe364e3550091fe8d1d8fcfbd3e2b23fa00943ca22e8a13f9d6c20cf7bf7846390498c5fb098c7cb45ff9cef461f9bddde50f4382a719e288af9731d
|
|
7
|
+
data.tar.gz: c91f8c1e74e4b1dc7fdeaa62870453e303018e7f5e4b0f25152a805cc20c15c04fea719caef6a6feb756f41291f319dd9ebca3b2275dbedc470e4ff22d5ed3fd
|
data/CHANGELOG.md
CHANGED
|
@@ -1,63 +1,89 @@
|
|
|
1
|
-
|
|
1
|
+
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Break Versioning](https://www.taoensso.com/break-versioning).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
4
9
|
|
|
5
10
|
### Added
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
### Changed
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
### Deprecated
|
|
10
15
|
|
|
11
|
-
|
|
16
|
+
### Removed
|
|
12
17
|
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
### Security
|
|
21
|
+
|
|
22
|
+
[Unreleased]: https://github.com/dry-rb/dry-logger/compare/v1.2.1...main
|
|
23
|
+
|
|
24
|
+
## [1.2.1] - 2025-12-16
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- Support Ruby 4.0 by adding the `"logger"` gem to the list of runtime dependencies. (@timriley in #39)
|
|
13
29
|
|
|
14
30
|
### Fixed
|
|
15
31
|
|
|
16
|
-
-
|
|
32
|
+
- Ensure changes to `logger.context` and calls to `logger.tagged` are threadsafe. (@timriley in #38)
|
|
33
|
+
|
|
34
|
+
[1.2.1]: https://github.com/dry-rb/dry-logger/compare/v1.2.0...v1.2.1
|
|
35
|
+
|
|
36
|
+
## [1.2.0] - 2025-11-05
|
|
17
37
|
|
|
18
38
|
### Changed
|
|
19
39
|
|
|
20
|
-
-
|
|
40
|
+
- When a block is given when logging, do not execute the block if the severity is lower than the configured logger level. (@p8 in #33)
|
|
41
|
+
- When a block is given when logging, and that block returns a hash, use that hash as the log payload. (@p8 in #34)
|
|
21
42
|
|
|
22
|
-
|
|
43
|
+
### Fixed
|
|
23
44
|
|
|
24
|
-
|
|
45
|
+
- When filtering logged data, filter on a copy of the given hash, rather then mutating it directly. (@timriley in #35)
|
|
25
46
|
|
|
47
|
+
## [1.1.0] - 2025-04-17
|
|
26
48
|
|
|
27
49
|
### Added
|
|
28
50
|
|
|
29
|
-
- Support
|
|
51
|
+
- Support `::Logger`'s log rotation in stream-based logger backends, via `shift_size:` and `shift_age:` arguments (@wuarmin in #31)
|
|
30
52
|
|
|
53
|
+
## [1.0.4] - 2024-05-10
|
|
31
54
|
|
|
32
|
-
|
|
55
|
+
### Fixed
|
|
33
56
|
|
|
34
|
-
|
|
57
|
+
- Accept log messages via given block, ensuring compatibility with standard Ruby logger (via #28) (@komidore64)
|
|
35
58
|
|
|
59
|
+
### Changed
|
|
36
60
|
|
|
37
|
-
|
|
61
|
+
- Drop support for Ruby 2.7 (via #29) (@timriley)
|
|
38
62
|
|
|
39
|
-
|
|
63
|
+
## [1.0.3] - 2022-12-09
|
|
40
64
|
|
|
65
|
+
### Added
|
|
41
66
|
|
|
42
|
-
|
|
67
|
+
- Support for ruby 2.7 (needs backports gem that *you* need to add to your Gemfile) (via #24) (@solnic)
|
|
43
68
|
|
|
44
|
-
## 1.0.
|
|
69
|
+
## [1.0.2] - 2022-11-24
|
|
45
70
|
|
|
71
|
+
### Fixed
|
|
72
|
+
|
|
73
|
+
- Handle `:log_if` in Proxy constructors (via #23) (@solnic)
|
|
74
|
+
|
|
75
|
+
## [1.0.1] - 2022-11-23
|
|
46
76
|
|
|
47
77
|
### Fixed
|
|
48
78
|
|
|
49
79
|
- Support for `log_if` in proxied loggers (via 81115320b490034ddf9dfe4f3775322b9271e0cd) (@solnic)
|
|
50
80
|
- Support exceptions and payloads in proxied loggers (via 93b3fd59ebbdc7e63620eb064694d58455df831f) (@solnic)
|
|
51
81
|
|
|
52
|
-
|
|
53
|
-
[Compare v1.0.0...v1.0.1](https://github.com/dry-rb/dry-logger/compare/v1.0.0...v1.0.1)
|
|
54
|
-
|
|
55
|
-
## 1.0.0 2022-11-17
|
|
82
|
+
## [1.0.0] - 2022-11-17
|
|
56
83
|
|
|
57
84
|
This is a port of the original Hanami logger from hanami-utils extended with support for logging
|
|
58
85
|
dispatchers that can log to different destinations and plenty more.
|
|
59
86
|
|
|
60
|
-
|
|
61
87
|
### Added
|
|
62
88
|
|
|
63
89
|
- Support arbitrary logging backends through proxy (via #12) (@solnic)
|
|
@@ -78,3 +104,11 @@ dispatchers that can log to different destinations and plenty more.
|
|
|
78
104
|
- `:rack` string log formatter which inlines request info and displays params at the end (@solnic)
|
|
79
105
|
- Conditional log dispatch via `#log_if` backend's predicate (via #9) (@solnic)
|
|
80
106
|
- Add support for shared context and tagged log entries (via #10) (@solnic)
|
|
107
|
+
|
|
108
|
+
[1.2.0]: https://github.com/dry-rb/dry-logger/compare/v1.1.0...v1.2.0
|
|
109
|
+
[1.1.0]: https://github.com/dry-rb/dry-logger/compare/v1.0.4...v1.1.0
|
|
110
|
+
[1.0.4]: https://github.com/dry-rb/dry-logger/compare/v1.0.3...v1.0.4
|
|
111
|
+
[1.0.3]: https://github.com/dry-rb/dry-logger/compare/v1.0.2...v1.0.3
|
|
112
|
+
[1.0.2]: https://github.com/dry-rb/dry-logger/compare/v1.0.1...v1.0.2
|
|
113
|
+
[1.0.1]: https://github.com/dry-rb/dry-logger/compare/v1.0.0...v1.0.1
|
|
114
|
+
[1.0.0]: https://github.com/dry-rb/dry-logger/releases/tag/v1.0.0
|
data/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2015-
|
|
3
|
+
Copyright (c) 2015-2025 Hanakai team
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
6
|
this software and associated documentation files (the "Software"), to deal in
|
|
@@ -18,3 +18,4 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
|
18
18
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
19
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
20
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
data/README.md
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
<!---
|
|
1
|
+
<!--- This file is synced from hanakai-rb/repo-sync -->
|
|
2
2
|
|
|
3
|
-
[
|
|
3
|
+
[rubygem]: https://rubygems.org/gems/dry-logger
|
|
4
4
|
[actions]: https://github.com/dry-rb/dry-logger/actions
|
|
5
5
|
|
|
6
|
-
# dry-logger [][
|
|
6
|
+
# dry-logger [][rubygem] [][actions]
|
|
7
7
|
|
|
8
8
|
## Links
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
## Supported Ruby versions
|
|
15
|
-
|
|
16
|
-
This library officially supports the following Ruby versions:
|
|
17
|
-
|
|
18
|
-
* MRI `>= 3.0`
|
|
19
|
-
* jruby `>= 9.4` (not tested on CI)
|
|
10
|
+
- [User documentation](https://dry-rb.org/gems/dry-logger)
|
|
11
|
+
- [API documentation](http://rubydoc.info/gems/dry-logger)
|
|
12
|
+
- [Forum](https://discourse.dry-rb.org)
|
|
20
13
|
|
|
21
14
|
## License
|
|
22
15
|
|
|
23
16
|
See `LICENSE` file.
|
|
17
|
+
|
data/dry-logger.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# This file is synced from hanakai-rb/repo-sync. To update it, edit repo-sync.yml.
|
|
4
4
|
|
|
5
5
|
lib = File.expand_path("lib", __dir__)
|
|
6
6
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
@@ -8,12 +8,12 @@ require "dry/logger/version"
|
|
|
8
8
|
|
|
9
9
|
Gem::Specification.new do |spec|
|
|
10
10
|
spec.name = "dry-logger"
|
|
11
|
-
spec.authors = ["
|
|
12
|
-
spec.email = ["
|
|
11
|
+
spec.authors = ["Hanakai team"]
|
|
12
|
+
spec.email = ["info@hanakai.org"]
|
|
13
13
|
spec.license = "MIT"
|
|
14
14
|
spec.version = Dry::Logger::VERSION.dup
|
|
15
15
|
|
|
16
|
-
spec.summary = "
|
|
16
|
+
spec.summary = "Lightweight structured logging for Ruby applications"
|
|
17
17
|
spec.description = spec.summary
|
|
18
18
|
spec.homepage = "https://dry-rb.org/gems/dry-logger"
|
|
19
19
|
spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-logger.gemspec", "lib/**/*"]
|
|
@@ -21,14 +21,20 @@ Gem::Specification.new do |spec|
|
|
|
21
21
|
spec.executables = []
|
|
22
22
|
spec.require_paths = ["lib"]
|
|
23
23
|
|
|
24
|
+
spec.extra_rdoc_files = ["README.md", "CHANGELOG.md", "LICENSE"]
|
|
25
|
+
|
|
24
26
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
25
27
|
spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-logger/blob/main/CHANGELOG.md"
|
|
26
28
|
spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-logger"
|
|
27
29
|
spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-logger/issues"
|
|
30
|
+
spec.metadata["funding_uri"] = "https://github.com/sponsors/hanami"
|
|
28
31
|
|
|
29
|
-
spec.required_ruby_version = ">= 3.
|
|
32
|
+
spec.required_ruby_version = ">= 3.2"
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
spec.add_runtime_dependency "logger"
|
|
32
35
|
|
|
36
|
+
spec.add_development_dependency "bundler"
|
|
37
|
+
spec.add_development_dependency "rake"
|
|
33
38
|
spec.add_development_dependency "rspec"
|
|
34
39
|
end
|
|
40
|
+
|
data/lib/dry/logger/constants.rb
CHANGED
|
@@ -6,6 +6,7 @@ require "pathname"
|
|
|
6
6
|
require "dry/logger/constants"
|
|
7
7
|
require "dry/logger/backends/proxy"
|
|
8
8
|
require "dry/logger/entry"
|
|
9
|
+
require "dry/logger/execution_context"
|
|
9
10
|
|
|
10
11
|
module Dry
|
|
11
12
|
module Logger
|
|
@@ -18,18 +19,6 @@ module Dry
|
|
|
18
19
|
# @api private
|
|
19
20
|
attr_reader :id
|
|
20
21
|
|
|
21
|
-
# (EXPERIMENTAL) Shared payload context
|
|
22
|
-
#
|
|
23
|
-
# @example
|
|
24
|
-
# logger.context[:component] = "test"
|
|
25
|
-
#
|
|
26
|
-
# logger.info "Hello World"
|
|
27
|
-
# # Hello World component=test
|
|
28
|
-
#
|
|
29
|
-
# @since 1.0.0
|
|
30
|
-
# @api public
|
|
31
|
-
attr_reader :context
|
|
32
|
-
|
|
33
22
|
# @since 1.0.0
|
|
34
23
|
# @api private
|
|
35
24
|
attr_reader :backends
|
|
@@ -86,21 +75,13 @@ module Dry
|
|
|
86
75
|
|
|
87
76
|
# @since 1.0.0
|
|
88
77
|
# @api private
|
|
89
|
-
def
|
|
90
|
-
Thread.current[:__dry_logger__] ||= {}
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
# @since 1.0.0
|
|
94
|
-
# @api private
|
|
95
|
-
def initialize(
|
|
96
|
-
id, backends: [], tags: [], context: self.class.default_context, **options
|
|
97
|
-
)
|
|
78
|
+
def initialize(id, backends: [], tags: [], context: {}, **options)
|
|
98
79
|
@id = id
|
|
99
80
|
@backends = backends
|
|
100
81
|
@options = {**options, progname: id}
|
|
101
82
|
@mutex = Mutex.new
|
|
102
|
-
@
|
|
103
|
-
@
|
|
83
|
+
@default_tags = tags.freeze
|
|
84
|
+
@default_context = context.freeze
|
|
104
85
|
@clock = Clock.new(**(options[:clock] || EMPTY_HASH))
|
|
105
86
|
@on_crash = options[:on_crash] || ON_CRASH
|
|
106
87
|
end
|
|
@@ -205,13 +186,20 @@ module Dry
|
|
|
205
186
|
# @since 1.0.0
|
|
206
187
|
# @return [true]
|
|
207
188
|
# @api public
|
|
208
|
-
def log(severity, message = nil, **payload, &block)
|
|
189
|
+
def log(severity, message = nil, **payload, &block) # rubocop:disable Metrics/PerceivedComplexity
|
|
190
|
+
return true if LEVELS[severity] < level
|
|
191
|
+
|
|
209
192
|
case message
|
|
210
193
|
when Hash then log(severity, **message, &block)
|
|
211
194
|
else
|
|
212
195
|
if block
|
|
213
196
|
progname = message
|
|
214
|
-
|
|
197
|
+
block_result = block.call
|
|
198
|
+
case block_result
|
|
199
|
+
when Hash then payload = block_result
|
|
200
|
+
else
|
|
201
|
+
message = block_result
|
|
202
|
+
end
|
|
215
203
|
end
|
|
216
204
|
progname ||= id
|
|
217
205
|
|
|
@@ -219,25 +207,40 @@ module Dry
|
|
|
219
207
|
clock: clock,
|
|
220
208
|
progname: progname,
|
|
221
209
|
severity: severity,
|
|
222
|
-
tags:
|
|
210
|
+
tags: current_tags,
|
|
223
211
|
message: message,
|
|
224
212
|
payload: {**context, **payload}
|
|
225
213
|
)
|
|
226
214
|
|
|
227
215
|
each_backend do |backend|
|
|
228
216
|
backend.__send__(severity, entry) if backend.log?(entry)
|
|
229
|
-
rescue StandardError =>
|
|
230
|
-
on_crash.(progname: id, exception:
|
|
217
|
+
rescue StandardError => exception
|
|
218
|
+
on_crash.(progname: id, exception: exception, message: message, payload: payload)
|
|
231
219
|
end
|
|
232
220
|
end
|
|
233
221
|
|
|
234
222
|
true
|
|
235
|
-
rescue StandardError =>
|
|
236
|
-
on_crash.(progname: id, exception:
|
|
223
|
+
rescue StandardError => exception
|
|
224
|
+
on_crash.(progname: id, exception: exception, message: message, payload: payload)
|
|
237
225
|
true
|
|
238
226
|
end
|
|
239
227
|
|
|
240
|
-
#
|
|
228
|
+
# Shared payload context
|
|
229
|
+
#
|
|
230
|
+
# @example
|
|
231
|
+
# logger.context[:component] = "test"
|
|
232
|
+
#
|
|
233
|
+
# logger.info "Hello World"
|
|
234
|
+
# # Hello World component=test
|
|
235
|
+
#
|
|
236
|
+
# @since 1.0.0
|
|
237
|
+
# @api public
|
|
238
|
+
def context
|
|
239
|
+
@context_key ||= :"context_#{object_id}"
|
|
240
|
+
ExecutionContext[@context_key] ||= @default_context.dup
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
# Tagged logging withing the provided block
|
|
241
244
|
#
|
|
242
245
|
# @example
|
|
243
246
|
# logger.tagged("red") do
|
|
@@ -251,10 +254,10 @@ module Dry
|
|
|
251
254
|
# @since 1.0.0
|
|
252
255
|
# @api public
|
|
253
256
|
def tagged(*tags)
|
|
254
|
-
|
|
257
|
+
tags_stack.push(tags)
|
|
255
258
|
yield
|
|
256
259
|
ensure
|
|
257
|
-
|
|
260
|
+
tags_stack.pop
|
|
258
261
|
end
|
|
259
262
|
|
|
260
263
|
# Add a new backend to an existing dispatcher
|
|
@@ -303,6 +306,17 @@ module Dry
|
|
|
303
306
|
each_backend { |backend| backend.public_send(meth, ...) }
|
|
304
307
|
true
|
|
305
308
|
end
|
|
309
|
+
|
|
310
|
+
private
|
|
311
|
+
|
|
312
|
+
def tags_stack
|
|
313
|
+
@tags_key ||= :"tags_#{object_id}"
|
|
314
|
+
ExecutionContext[@tags_key] ||= @default_tags.dup
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
def current_tags
|
|
318
|
+
tags_stack.flatten
|
|
319
|
+
end
|
|
306
320
|
end
|
|
307
321
|
end
|
|
308
322
|
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dry
|
|
4
|
+
module Logger
|
|
5
|
+
# Provides isolated thread-local storage for logger values.
|
|
6
|
+
#
|
|
7
|
+
# @api private
|
|
8
|
+
module ExecutionContext
|
|
9
|
+
CONTEXT_KEY = :__dry_logger__
|
|
10
|
+
|
|
11
|
+
class << self
|
|
12
|
+
# Returns a value from the current execution context.
|
|
13
|
+
#
|
|
14
|
+
# @param key [Symbol] the key to retrieve
|
|
15
|
+
#
|
|
16
|
+
# @return [Object, nil] the stored value, or nil if no value has been stored
|
|
17
|
+
def [](key)
|
|
18
|
+
context[key]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Sets a value in the current execution context.
|
|
22
|
+
#
|
|
23
|
+
# @param key [Symbol] the key to store
|
|
24
|
+
# @param value [Object] the value to store
|
|
25
|
+
#
|
|
26
|
+
# @return [Object] the stored value
|
|
27
|
+
def []=(key, value)
|
|
28
|
+
context[key] = value
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Clears all values from the current execution context.
|
|
32
|
+
#
|
|
33
|
+
# @return [self]
|
|
34
|
+
def clear
|
|
35
|
+
current_store[CONTEXT_KEY] = {}
|
|
36
|
+
self
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def context
|
|
42
|
+
current_store[CONTEXT_KEY] ||= {}
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def current_store
|
|
46
|
+
Thread.current
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
data/lib/dry/logger/filter.rb
CHANGED
|
@@ -5,18 +5,17 @@ module Dry
|
|
|
5
5
|
# Filtering logic
|
|
6
6
|
# Originaly copied from hanami/utils (see Hanami::Logger)
|
|
7
7
|
#
|
|
8
|
-
# @since 0.1.0
|
|
9
8
|
# @api private
|
|
10
9
|
class Filter
|
|
11
|
-
# @since 0.1.0
|
|
12
10
|
# @api private
|
|
13
11
|
def initialize(filters = [])
|
|
14
12
|
@filters = filters
|
|
15
13
|
end
|
|
16
14
|
|
|
17
|
-
# @since 0.1.0
|
|
18
15
|
# @api private
|
|
19
16
|
def call(hash)
|
|
17
|
+
hash = _deep_dup(hash)
|
|
18
|
+
|
|
20
19
|
_filtered_keys(hash).each do |key|
|
|
21
20
|
*keys, last = _actual_keys(hash, key.split("."))
|
|
22
21
|
keys.inject(hash, :fetch)[last] = "[FILTERED]"
|
|
@@ -27,12 +26,8 @@ module Dry
|
|
|
27
26
|
|
|
28
27
|
private
|
|
29
28
|
|
|
30
|
-
# @since 0.1.0
|
|
31
|
-
# @api private
|
|
32
29
|
attr_reader :filters
|
|
33
30
|
|
|
34
|
-
# @since 0.1.0
|
|
35
|
-
# @api private
|
|
36
31
|
def _filtered_keys(hash)
|
|
37
32
|
_key_paths(hash).select { |key|
|
|
38
33
|
filters.any? { |filter|
|
|
@@ -41,22 +36,16 @@ module Dry
|
|
|
41
36
|
}
|
|
42
37
|
end
|
|
43
38
|
|
|
44
|
-
# @since 0.1.0
|
|
45
|
-
# @api private
|
|
46
39
|
def _key_paths(hash, base = nil)
|
|
47
40
|
hash.inject([]) do |results, (k, v)|
|
|
48
41
|
results + (_key_paths?(v) ? _key_paths(v, _build_path(base, k)) : [_build_path(base, k)])
|
|
49
42
|
end
|
|
50
43
|
end
|
|
51
44
|
|
|
52
|
-
# @since 0.1.0
|
|
53
|
-
# @api private
|
|
54
45
|
def _build_path(base, key)
|
|
55
46
|
[base, key.to_s].compact.join(".")
|
|
56
47
|
end
|
|
57
48
|
|
|
58
|
-
# @since 0.1.0
|
|
59
|
-
# @api private
|
|
60
49
|
def _actual_keys(hash, keys)
|
|
61
50
|
search_in = hash
|
|
62
51
|
|
|
@@ -70,13 +59,17 @@ module Dry
|
|
|
70
59
|
# Check if the given value can be iterated (`Enumerable`) and that isn't a `File`.
|
|
71
60
|
# This is useful to detect closed `Tempfiles`.
|
|
72
61
|
#
|
|
73
|
-
# @since 0.1.0
|
|
74
|
-
# @api private
|
|
75
|
-
#
|
|
76
62
|
# @see https://github.com/hanami/utils/pull/342
|
|
77
63
|
def _key_paths?(value)
|
|
78
64
|
value.is_a?(Enumerable) && !value.is_a?(File)
|
|
79
65
|
end
|
|
66
|
+
|
|
67
|
+
# Returns a deeply duplicated hash to avoid mutations of the original.
|
|
68
|
+
def _deep_dup(hash)
|
|
69
|
+
hash.transform_values { |value|
|
|
70
|
+
value.is_a?(Hash) ? _deep_dup(value) : value
|
|
71
|
+
}
|
|
72
|
+
end
|
|
80
73
|
end
|
|
81
74
|
end
|
|
82
75
|
end
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "set"
|
|
4
|
-
|
|
5
3
|
require_relative "template"
|
|
6
4
|
require_relative "structured"
|
|
7
5
|
|
|
@@ -97,7 +95,7 @@ module Dry
|
|
|
97
95
|
def format_exception(value)
|
|
98
96
|
[
|
|
99
97
|
"#{value.message} (#{value.class})",
|
|
100
|
-
format_backtrace(value.backtrace ||
|
|
98
|
+
format_backtrace(value.backtrace || EMPTY_ARRAY)
|
|
101
99
|
].join(NEW_LINE)
|
|
102
100
|
end
|
|
103
101
|
|
|
@@ -140,7 +138,7 @@ module Dry
|
|
|
140
138
|
def severity_colors
|
|
141
139
|
@severity_colors ||= DEFAULT_SEVERITY_COLORS.merge(
|
|
142
140
|
(options[:severity_colors] || EMPTY_HASH)
|
|
143
|
-
.
|
|
141
|
+
.transform_keys { |key| LEVELS[key.to_s] }
|
|
144
142
|
)
|
|
145
143
|
end
|
|
146
144
|
end
|
data/lib/dry/logger/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,16 +1,57 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dry-logger
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1
|
|
4
|
+
version: 1.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
8
|
-
- Peter Solnica
|
|
7
|
+
- Hanakai team
|
|
9
8
|
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date: 2025-
|
|
11
|
+
date: 2025-12-15 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: logger
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: bundler
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rake
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
14
55
|
- !ruby/object:Gem::Dependency
|
|
15
56
|
name: rspec
|
|
16
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -25,13 +66,15 @@ dependencies:
|
|
|
25
66
|
- - ">="
|
|
26
67
|
- !ruby/object:Gem::Version
|
|
27
68
|
version: '0'
|
|
28
|
-
description:
|
|
69
|
+
description: Lightweight structured logging for Ruby applications
|
|
29
70
|
email:
|
|
30
|
-
-
|
|
31
|
-
- peter@solnica.online
|
|
71
|
+
- info@hanakai.org
|
|
32
72
|
executables: []
|
|
33
73
|
extensions: []
|
|
34
|
-
extra_rdoc_files:
|
|
74
|
+
extra_rdoc_files:
|
|
75
|
+
- README.md
|
|
76
|
+
- CHANGELOG.md
|
|
77
|
+
- LICENSE
|
|
35
78
|
files:
|
|
36
79
|
- CHANGELOG.md
|
|
37
80
|
- LICENSE
|
|
@@ -47,6 +90,7 @@ files:
|
|
|
47
90
|
- lib/dry/logger/constants.rb
|
|
48
91
|
- lib/dry/logger/dispatcher.rb
|
|
49
92
|
- lib/dry/logger/entry.rb
|
|
93
|
+
- lib/dry/logger/execution_context.rb
|
|
50
94
|
- lib/dry/logger/filter.rb
|
|
51
95
|
- lib/dry/logger/formatters/colors.rb
|
|
52
96
|
- lib/dry/logger/formatters/json.rb
|
|
@@ -64,6 +108,7 @@ metadata:
|
|
|
64
108
|
changelog_uri: https://github.com/dry-rb/dry-logger/blob/main/CHANGELOG.md
|
|
65
109
|
source_code_uri: https://github.com/dry-rb/dry-logger
|
|
66
110
|
bug_tracker_uri: https://github.com/dry-rb/dry-logger/issues
|
|
111
|
+
funding_uri: https://github.com/sponsors/hanami
|
|
67
112
|
post_install_message:
|
|
68
113
|
rdoc_options: []
|
|
69
114
|
require_paths:
|
|
@@ -72,7 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
72
117
|
requirements:
|
|
73
118
|
- - ">="
|
|
74
119
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '3.
|
|
120
|
+
version: '3.2'
|
|
76
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
122
|
requirements:
|
|
78
123
|
- - ">="
|
|
@@ -82,5 +127,5 @@ requirements: []
|
|
|
82
127
|
rubygems_version: 3.3.27
|
|
83
128
|
signing_key:
|
|
84
129
|
specification_version: 4
|
|
85
|
-
summary:
|
|
130
|
+
summary: Lightweight structured logging for Ruby applications
|
|
86
131
|
test_files: []
|