lumberjack 1.3.1 → 1.3.3
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 +16 -0
- data/VERSION +1 -1
- data/lib/lumberjack/logger.rb +1 -3
- data/lib/lumberjack/utils.rb +48 -2
- data/lumberjack.gemspec +6 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2be09b55c4a7ac6187425bdf0a6ded2a983301bd2698519174843e753ae27bb5
|
4
|
+
data.tar.gz: 131dd6986a741ba4b819ef2de652c4c5c6576bd970138d7a9883c4a9eb470237
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d164abb04d3f06d8b2ec0f1653eeb9b6663fba66c8a095bd2841ecb7fe2ffc91a860e7662485e3a2e71acb058c9dadc35c3cd775f0802a2b1946f94fe8c39ef
|
7
|
+
data.tar.gz: 90f918cda88678f8a12a2ed84dc789eeb250c6ba5af9b70f7c8daddafb87196525732a2513bfe719eeeadc37c5f642c4af3e0cc80b49ef8a0f12ea0075c4ff9a
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## 1.3.3
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- Added `Lumberjack::Utils#expand_tags` method to expand a hash of tags that may contain nested hashes or dot notation keys.
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
|
15
|
+
- Updated `Lumberjack::Utils#flatten_tags` to convert all keys to strings.
|
16
|
+
|
17
|
+
## 1.3.2
|
18
|
+
|
19
|
+
### Fixed
|
20
|
+
|
21
|
+
- Fixed `NoMethodError` when setting the device via the `Lumberjack::Logger#device=` method.
|
22
|
+
|
7
23
|
## 1.3.1
|
8
24
|
|
9
25
|
### Added
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.3
|
data/lib/lumberjack/logger.rb
CHANGED
@@ -96,9 +96,7 @@ module Lumberjack
|
|
96
96
|
# @param [Lumberjack::Device] device The new logging device.
|
97
97
|
# @return [void]
|
98
98
|
def device=(device)
|
99
|
-
@logdev =
|
100
|
-
open_device(device, options)
|
101
|
-
end
|
99
|
+
@logdev = device.nil? ? nil : open_device(device, {})
|
102
100
|
end
|
103
101
|
|
104
102
|
# Get the timestamp format on the device if it has one.
|
data/lib/lumberjack/utils.rb
CHANGED
@@ -103,7 +103,10 @@ module Lumberjack
|
|
103
103
|
# Flatten a tag hash to a single level hash with dot notation for nested keys.
|
104
104
|
#
|
105
105
|
# @param tag_hash [Hash] The hash to flatten.
|
106
|
-
# @return [Hash] The flattened hash.
|
106
|
+
# @return [Hash<String, Object>] The flattened hash.
|
107
|
+
# @example
|
108
|
+
# expand_tags(user: {id: 123, name: "Alice"}, action: "login")})
|
109
|
+
# # => {"user.id" => 123, "user.name" => "Alice", "action" => "login"}
|
107
110
|
def flatten_tags(tag_hash)
|
108
111
|
return {} unless tag_hash.is_a?(Hash)
|
109
112
|
|
@@ -113,11 +116,26 @@ module Lumberjack
|
|
113
116
|
result["#{key}.#{sub_key}"] = sub_value
|
114
117
|
end
|
115
118
|
else
|
116
|
-
result[key] = value
|
119
|
+
result[key.to_s] = value
|
117
120
|
end
|
118
121
|
end
|
119
122
|
end
|
120
123
|
|
124
|
+
# Expand a hash of tags that may contain nested hashes or dot notation keys. Dot notation tags
|
125
|
+
# will be expanded into nested hashes.
|
126
|
+
#
|
127
|
+
# @param tags [Hash] The hash of tags to expand.
|
128
|
+
# @return [Hash] The expanded hash with dot notation keys.
|
129
|
+
#
|
130
|
+
# @example
|
131
|
+
# expand_tags({"user.id" => 123, "user.name" => "Alice", "action" => "login"})
|
132
|
+
# # => {"user" => {"id" => 123, "name" => "Alice"}, "action" => "login"}
|
133
|
+
def expand_tags(tags)
|
134
|
+
return {} unless tags.is_a?(Hash)
|
135
|
+
|
136
|
+
expand_dot_notation_hash(tags)
|
137
|
+
end
|
138
|
+
|
121
139
|
private
|
122
140
|
|
123
141
|
def slugify(str)
|
@@ -128,6 +146,34 @@ module Lumberjack
|
|
128
146
|
str.chomp!("-")
|
129
147
|
str
|
130
148
|
end
|
149
|
+
|
150
|
+
def expand_dot_notation_hash(hash, expanded = {})
|
151
|
+
return hash unless hash.is_a?(Hash)
|
152
|
+
|
153
|
+
hash.each do |key, value|
|
154
|
+
key = key.to_s
|
155
|
+
if key.include?(".")
|
156
|
+
main_key, sub_key = key.split(".", 2)
|
157
|
+
main_key_hash = expanded[main_key]
|
158
|
+
unless main_key_hash.is_a?(Hash)
|
159
|
+
main_key_hash = {}
|
160
|
+
expanded[main_key] = main_key_hash
|
161
|
+
end
|
162
|
+
expand_dot_notation_hash({sub_key => value}, main_key_hash)
|
163
|
+
elsif value.is_a?(Hash)
|
164
|
+
key_hash = expanded[key]
|
165
|
+
unless key_hash.is_a?(Hash)
|
166
|
+
key_hash = {}
|
167
|
+
expanded[key] = key_hash
|
168
|
+
end
|
169
|
+
expand_dot_notation_hash(value, key_hash)
|
170
|
+
else
|
171
|
+
expanded[key] = value
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
expanded
|
176
|
+
end
|
131
177
|
end
|
132
178
|
end
|
133
179
|
end
|
data/lumberjack.gemspec
CHANGED
@@ -8,6 +8,12 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.homepage = "https://github.com/bdurand/lumberjack"
|
9
9
|
spec.license = "MIT"
|
10
10
|
|
11
|
+
spec.metadata = {
|
12
|
+
"homepage_uri" => spec.homepage,
|
13
|
+
"source_code_uri" => spec.homepage,
|
14
|
+
"changelog_uri" => "#{spec.homepage}/blob/main/CHANGELOG.md"
|
15
|
+
}
|
16
|
+
|
11
17
|
# Specify which files should be added to the gem when it is released.
|
12
18
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
13
19
|
ignore_files = %w[
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lumberjack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Durand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-07-
|
11
|
+
date: 2025-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -78,7 +78,10 @@ files:
|
|
78
78
|
homepage: https://github.com/bdurand/lumberjack
|
79
79
|
licenses:
|
80
80
|
- MIT
|
81
|
-
metadata:
|
81
|
+
metadata:
|
82
|
+
homepage_uri: https://github.com/bdurand/lumberjack
|
83
|
+
source_code_uri: https://github.com/bdurand/lumberjack
|
84
|
+
changelog_uri: https://github.com/bdurand/lumberjack/blob/main/CHANGELOG.md
|
82
85
|
post_install_message:
|
83
86
|
rdoc_options: []
|
84
87
|
require_paths:
|