lumberjack 1.3.2 → 1.3.4
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 +20 -0
- data/VERSION +1 -1
- data/lib/lumberjack/logger.rb +16 -7
- data/lib/lumberjack/utils.rb +48 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db9d72af596912080ab89e900718d2dc1a4d27dda1eb8320d540fa096325b209
|
4
|
+
data.tar.gz: 0737c0a2bde27fa687af82a6ac65f8ede65abdbe175462bc8c39e515569d3a23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 941b206a2ffcb38760669f04658f9a52ec6eee063e2d76505db7c29c0a2f6b7e2d481fdffa0c88ee6eadc189fcb416e89b0e8490d8eea8513ededefd2ccef21b
|
7
|
+
data.tar.gz: fa95906ee0eb896b77eb33958223831a4b8f8c43b6f1a84a21df93388ee7f37c974c0fb0bdbc1bda1e9836af00d26aed0c11576409bcb153a3cd7dab3e4373c1
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,26 @@ 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.4
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- Added `Lumberjack::Logger#with_progname` alias for `set_progname` to match the naming convention used for setting temporary levels.
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
|
15
|
+
- Ensure that the safety check for circular calls to `Lumberjack::Logger#add_entry` cannot lose state.
|
16
|
+
|
17
|
+
## 1.3.3
|
18
|
+
|
19
|
+
### Added
|
20
|
+
|
21
|
+
- Added `Lumberjack::Utils#expand_tags` method to expand a hash of tags that may contain nested hashes or dot notation keys.
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
|
25
|
+
- Updated `Lumberjack::Utils#flatten_tags` to convert all keys to strings.
|
26
|
+
|
7
27
|
## 1.3.2
|
8
28
|
|
9
29
|
### Fixed
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.4
|
data/lib/lumberjack/logger.rb
CHANGED
@@ -200,12 +200,12 @@ module Lumberjack
|
|
200
200
|
# logger.add_entry(:warn, "Request took a long time")
|
201
201
|
# logger.add_entry(Logger::DEBUG){"Start processing with options #{options.inspect}"}
|
202
202
|
def add_entry(severity, message, progname = nil, tags = nil)
|
203
|
-
|
204
|
-
|
205
|
-
|
203
|
+
severity = Severity.label_to_level(severity) unless severity.is_a?(Integer)
|
204
|
+
return true unless device && severity && severity >= level
|
205
|
+
return true if Thread.current[:lumberjack_logging]
|
206
206
|
|
207
|
-
|
208
|
-
Thread.current[:lumberjack_logging] = true
|
207
|
+
begin
|
208
|
+
Thread.current[:lumberjack_logging] = true # Prevent circular calls to add_entry
|
209
209
|
|
210
210
|
time = Time.now
|
211
211
|
|
@@ -380,7 +380,7 @@ module Lumberjack
|
|
380
380
|
|
381
381
|
# Return +true+ if +INFO+ messages are being logged.
|
382
382
|
#
|
383
|
-
|
383
|
+
# @return [Boolean]
|
384
384
|
def info?
|
385
385
|
level <= INFO
|
386
386
|
end
|
@@ -465,7 +465,7 @@ module Lumberjack
|
|
465
465
|
# @param [Integer, String, Symbol] level The log level to use inside the block.
|
466
466
|
# @return [Object] The result of the block.
|
467
467
|
def log_at(level, &block)
|
468
|
-
|
468
|
+
with_level(level, &block)
|
469
469
|
end
|
470
470
|
|
471
471
|
# Set the program name that is associated with log messages. If a block
|
@@ -481,6 +481,15 @@ module Lumberjack
|
|
481
481
|
end
|
482
482
|
end
|
483
483
|
|
484
|
+
# Set the logger progname for the duration of the block.
|
485
|
+
#
|
486
|
+
# @yield [Object] The block to execute with the program name set.
|
487
|
+
# @param [String] value The program name to use.
|
488
|
+
# @return [Object] The result of the block.
|
489
|
+
def with_progname(value, &block)
|
490
|
+
set_progname(value, &block)
|
491
|
+
end
|
492
|
+
|
484
493
|
# Get the program name associated with log messages.
|
485
494
|
#
|
486
495
|
# @return [String]
|
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
|
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.4
|
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-
|
11
|
+
date: 2025-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|