lumberjack 2.0.4 → 2.1.0
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/ARCHITECTURE.md +0 -17
- data/CHANGELOG.md +58 -0
- data/README.md +35 -0
- data/UPGRADE_GUIDE.md +1 -1
- data/VERSION +1 -1
- data/lib/lumberjack/attribute_formatter.rb +0 -51
- data/lib/lumberjack/context.rb +6 -1
- data/lib/lumberjack/context_locals.rb +10 -2
- data/lib/lumberjack/context_logger.rb +14 -4
- data/lib/lumberjack/device/buffer.rb +52 -37
- data/lib/lumberjack/device/multi.rb +2 -2
- data/lib/lumberjack/device/test.rb +70 -13
- data/lib/lumberjack/device/writer.rb +35 -12
- data/lib/lumberjack/device.rb +0 -2
- data/lib/lumberjack/device_registry.rb +7 -6
- data/lib/lumberjack/entry_formatter.rb +4 -2
- data/lib/lumberjack/formatter/structured_formatter.rb +4 -4
- data/lib/lumberjack/formatter/tags_formatter.rb +3 -3
- data/lib/lumberjack/formatter.rb +0 -11
- data/lib/lumberjack/formatter_registry.rb +7 -6
- data/lib/lumberjack/io_compatibility.rb +8 -0
- data/lib/lumberjack/log_entry.rb +13 -46
- data/lib/lumberjack/log_entry_matcher/indifferent_hash.rb +83 -0
- data/lib/lumberjack/log_entry_matcher/score.rb +12 -4
- data/lib/lumberjack/log_entry_matcher.rb +229 -28
- data/lib/lumberjack/logger.rb +19 -185
- data/lib/lumberjack/template.rb +65 -42
- data/lib/lumberjack/template_registry.rb +7 -6
- data/lib/lumberjack/utils.rb +1 -26
- data/lib/lumberjack.rb +5 -25
- data/lumberjack.gemspec +0 -2
- metadata +2 -21
- data/lib/lumberjack/device/date_rolling_log_file.rb +0 -22
- data/lib/lumberjack/device/size_rolling_log_file.rb +0 -22
- data/lib/lumberjack/formatter/tagged_message.rb +0 -17
- data/lib/lumberjack/tag_context.rb +0 -15
- data/lib/lumberjack/tag_formatter.rb +0 -31
- data/lib/lumberjack/tags.rb +0 -36
data/lib/lumberjack/template.rb
CHANGED
|
@@ -101,9 +101,8 @@ module Lumberjack
|
|
|
101
101
|
MILLISECOND_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%3N"
|
|
102
102
|
MICROSECOND_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%6N"
|
|
103
103
|
PLACEHOLDER_PATTERN = /{{ *((?:[^}]|}(?!}))*) *}}/i
|
|
104
|
-
V1_PLACEHOLDER_PATTERN = /:[a-z0-9_.-]+/i
|
|
105
104
|
RESET_CHAR = "\e[0m"
|
|
106
|
-
private_constant :TEMPLATE_ARGUMENT_ORDER, :MILLISECOND_TIME_FORMAT, :MICROSECOND_TIME_FORMAT, :PLACEHOLDER_PATTERN, :
|
|
105
|
+
private_constant :TEMPLATE_ARGUMENT_ORDER, :MILLISECOND_TIME_FORMAT, :MICROSECOND_TIME_FORMAT, :PLACEHOLDER_PATTERN, :RESET_CHAR
|
|
107
106
|
|
|
108
107
|
class << self
|
|
109
108
|
def colorize_entry(formatted_string, entry)
|
|
@@ -133,22 +132,10 @@ module Lumberjack
|
|
|
133
132
|
def initialize(first_line = nil, additional_lines: nil, time_format: nil, attribute_format: nil, colorize: false)
|
|
134
133
|
first_line ||= DEFAULT_FIRST_LINE_TEMPLATE
|
|
135
134
|
first_line = "#{first_line.chomp}#{Lumberjack::LINE_SEPARATOR}"
|
|
136
|
-
|
|
137
|
-
Utils.deprecated("Template.v1", "Templates now use {{placeholder}} instead of :placeholder and :tags has been replaced with {{attributes}}.") do
|
|
138
|
-
@first_line_template, @first_line_attributes = compile_v1(first_line)
|
|
139
|
-
end
|
|
140
|
-
else
|
|
141
|
-
@first_line_template, @first_line_attributes = compile(first_line)
|
|
142
|
-
end
|
|
135
|
+
@first_line_template, @first_line_attributes = compile(first_line)
|
|
143
136
|
|
|
144
137
|
additional_lines ||= DEFAULT_ADDITIONAL_LINES_TEMPLATE
|
|
145
|
-
|
|
146
|
-
Utils.deprecated("Template.v1", "Templates now use {{placeholder}} instead of :placeholder and :tags has been replaced with {{attributes}}.") do
|
|
147
|
-
@additional_line_template, @additional_line_attributes = compile_v1(additional_lines)
|
|
148
|
-
end
|
|
149
|
-
else
|
|
150
|
-
@additional_line_template, @additional_line_attributes = compile(additional_lines)
|
|
151
|
-
end
|
|
138
|
+
@additional_line_template, @additional_line_attributes = compile(additional_lines)
|
|
152
139
|
|
|
153
140
|
@attribute_template = attribute_format || DEFAULT_ATTRIBUTE_FORMAT
|
|
154
141
|
unless @attribute_template.scan("%s").size == 2
|
|
@@ -160,6 +147,7 @@ module Lumberjack
|
|
|
160
147
|
self.datetime_format = (time_format || :milliseconds)
|
|
161
148
|
|
|
162
149
|
@colorize = colorize
|
|
150
|
+
@pid_cache = nil
|
|
163
151
|
end
|
|
164
152
|
|
|
165
153
|
# Set the datetime format used for timestamp formatting in the template.
|
|
@@ -177,6 +165,15 @@ module Lumberjack
|
|
|
177
165
|
format = MICROSECOND_TIME_FORMAT
|
|
178
166
|
end
|
|
179
167
|
@time_formatter = Formatter::DateTimeFormatter.new(format)
|
|
168
|
+
|
|
169
|
+
# Formatted timestamps can only be cached for the built-in formats where the
|
|
170
|
+
# subsecond precision is known.
|
|
171
|
+
@time_cache_units, @time_cache_divisor = if format == MILLISECOND_TIME_FORMAT
|
|
172
|
+
[1_000, 1_000_000]
|
|
173
|
+
elsif format == MICROSECOND_TIME_FORMAT
|
|
174
|
+
[1_000_000, 1_000]
|
|
175
|
+
end
|
|
176
|
+
@time_cache = nil
|
|
180
177
|
end
|
|
181
178
|
|
|
182
179
|
# Get the current datetime format string used for timestamp formatting.
|
|
@@ -202,7 +199,7 @@ module Lumberjack
|
|
|
202
199
|
first_line = additional_lines.shift
|
|
203
200
|
end
|
|
204
201
|
|
|
205
|
-
formatted_time =
|
|
202
|
+
formatted_time = cached_formatted_time(entry.time) if @template_include_time
|
|
206
203
|
severity = entry.severity_data
|
|
207
204
|
format_args = [
|
|
208
205
|
formatted_time,
|
|
@@ -212,7 +209,7 @@ module Lumberjack
|
|
|
212
209
|
severity.emoji,
|
|
213
210
|
severity.level,
|
|
214
211
|
entry.progname,
|
|
215
|
-
entry.pid,
|
|
212
|
+
cached_pid_string(entry.pid),
|
|
216
213
|
first_line
|
|
217
214
|
]
|
|
218
215
|
append_attribute_args!(format_args, entry.attributes, @first_line_attributes)
|
|
@@ -237,11 +234,61 @@ module Lumberjack
|
|
|
237
234
|
|
|
238
235
|
message = Template.colorize_entry(message, entry) if @colorize
|
|
239
236
|
|
|
237
|
+
# Normalize the output to end with exactly one line separator and no trailing
|
|
238
|
+
# whitespace so the writer can send it to the stream without any further processing.
|
|
239
|
+
message.rstrip!
|
|
240
|
+
message << Lumberjack::LINE_SEPARATOR
|
|
241
|
+
|
|
240
242
|
message
|
|
241
243
|
end
|
|
242
244
|
|
|
243
245
|
private
|
|
244
246
|
|
|
247
|
+
# Format a timestamp, reusing the last formatted value when the time falls within
|
|
248
|
+
# the same subsecond tick as the previous entry. Formatting a time is relatively
|
|
249
|
+
# expensive, so this saves both CPU and a string allocation for entries logged in
|
|
250
|
+
# quick succession. The cache is a single frozen array published with one instance
|
|
251
|
+
# variable write, so concurrent readers see either the old or the new value; the
|
|
252
|
+
# worst case under contention is a redundant recompute, never an incorrect string.
|
|
253
|
+
#
|
|
254
|
+
# @param time [Time] The timestamp to format
|
|
255
|
+
# @return [String] The formatted timestamp
|
|
256
|
+
def cached_formatted_time(time)
|
|
257
|
+
# Only Time exposes the epoch, nanosecond, and offset accessors the cache key needs.
|
|
258
|
+
# Other timestamp objects (Date, DateTime, etc.) are always formatted directly.
|
|
259
|
+
return @time_formatter.call(time) unless @time_cache_divisor && time.is_a?(Time)
|
|
260
|
+
|
|
261
|
+
# The key is the epoch time in the same units as the format's subsecond precision.
|
|
262
|
+
# Integer division truncates the same way the strftime %N directive does. The UTC
|
|
263
|
+
# offset must be part of the key because the formats render wall-clock components.
|
|
264
|
+
key = (time.to_i * @time_cache_units) + (time.nsec / @time_cache_divisor)
|
|
265
|
+
offset = time.utc_offset
|
|
266
|
+
cached = @time_cache
|
|
267
|
+
return cached[2] if cached && cached[0] == key && cached[1] == offset && cached[2]
|
|
268
|
+
|
|
269
|
+
formatted = @time_formatter.call(time).to_s.freeze
|
|
270
|
+
@time_cache = [key, offset, formatted].freeze
|
|
271
|
+
formatted
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
# Convert a process id to a string, caching the result since the pid rarely changes.
|
|
275
|
+
# Passing an Integer to sprintf allocates a new string on every call; reusing the
|
|
276
|
+
# frozen string avoids that. Uses the same benign-race publication pattern as the
|
|
277
|
+
# timestamp cache.
|
|
278
|
+
#
|
|
279
|
+
# @param pid [Integer, nil] The process id
|
|
280
|
+
# @return [String, nil] The pid as a string
|
|
281
|
+
def cached_pid_string(pid)
|
|
282
|
+
return pid unless pid.is_a?(Integer)
|
|
283
|
+
|
|
284
|
+
cached = @pid_cache
|
|
285
|
+
return cached[1] if cached && cached[0] == pid
|
|
286
|
+
|
|
287
|
+
pid_string = pid.to_s.freeze
|
|
288
|
+
@pid_cache = [pid, pid_string].freeze
|
|
289
|
+
pid_string
|
|
290
|
+
end
|
|
291
|
+
|
|
245
292
|
# Build the arguments array for sprintf formatting by appending attribute values.
|
|
246
293
|
# This method handles both the general :attributes placeholder and specific
|
|
247
294
|
# attribute placeholders defined in the template.
|
|
@@ -295,29 +342,5 @@ module Lumberjack
|
|
|
295
342
|
end
|
|
296
343
|
[template, attribute_vars]
|
|
297
344
|
end
|
|
298
|
-
|
|
299
|
-
# Parse and compile a template string into a sprintf-compatible format string
|
|
300
|
-
# and extract attribute variable names. This method handles placeholder
|
|
301
|
-
# substitution and escape sequence processing.
|
|
302
|
-
#
|
|
303
|
-
# @param template [String] The raw template string with placeholders
|
|
304
|
-
# @return [Array<String, Array<String>>] A tuple of [compiled_template, attribute_vars]
|
|
305
|
-
def compile_v1(template) # :nodoc:
|
|
306
|
-
template = template.gsub(":tags", ":attributes").gsub(/ ?:attributes/, ":attributes")
|
|
307
|
-
template = template.gsub(/%(?!%)/, "%%")
|
|
308
|
-
|
|
309
|
-
attribute_vars = []
|
|
310
|
-
template = template.gsub(V1_PLACEHOLDER_PATTERN) do |match|
|
|
311
|
-
var_name = match[1, match.length]
|
|
312
|
-
position = TEMPLATE_ARGUMENT_ORDER.index(var_name)
|
|
313
|
-
if position
|
|
314
|
-
"%#{position + 1}$s"
|
|
315
|
-
else
|
|
316
|
-
attribute_vars << var_name
|
|
317
|
-
"%#{TEMPLATE_ARGUMENT_ORDER.size + attribute_vars.size}$s"
|
|
318
|
-
end
|
|
319
|
-
end
|
|
320
|
-
[template, attribute_vars]
|
|
321
|
-
end
|
|
322
345
|
end
|
|
323
346
|
end
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
module Lumberjack
|
|
4
4
|
class TemplateRegistry
|
|
5
5
|
@templates = {}
|
|
6
|
+
@lock = Mutex.new
|
|
6
7
|
|
|
7
8
|
class << self
|
|
8
9
|
# Register a log template class with a symbol.
|
|
@@ -14,15 +15,15 @@ module Lumberjack
|
|
|
14
15
|
raise ArgumentError.new("template must be a String, Class, or respond to :call")
|
|
15
16
|
end
|
|
16
17
|
|
|
17
|
-
@templates[name.to_sym] = template
|
|
18
|
+
@lock.synchronize { @templates[name.to_sym] = template }
|
|
18
19
|
end
|
|
19
20
|
|
|
20
|
-
# Remove a template from the registry.
|
|
21
|
+
# Remove a template from the registry.
|
|
21
22
|
#
|
|
22
23
|
# @param name [Symbol] The name of the template to remove.
|
|
23
24
|
# @return [void]
|
|
24
25
|
def remove(name)
|
|
25
|
-
@templates.delete(name.to_sym)
|
|
26
|
+
@lock.synchronize { @templates.delete(name.to_sym) }
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
# Check if a template is registered.
|
|
@@ -30,7 +31,7 @@ module Lumberjack
|
|
|
30
31
|
# @param name [Symbol] The name of the template.
|
|
31
32
|
# @return [Boolean] True if the template is registered, false otherwise.
|
|
32
33
|
def registered?(name)
|
|
33
|
-
@templates.include(name.to_sym)
|
|
34
|
+
@lock.synchronize { @templates.include?(name.to_sym) }
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
# Get a registered log template class by its symbol.
|
|
@@ -38,7 +39,7 @@ module Lumberjack
|
|
|
38
39
|
# @param name [Symbol] The symbol of the registered log template class.
|
|
39
40
|
# @return [Class, nil] The registered log template class, or nil if not found.
|
|
40
41
|
def template(name, options = {})
|
|
41
|
-
template = @templates[name.to_sym]
|
|
42
|
+
template = @lock.synchronize { @templates[name.to_sym] }
|
|
42
43
|
if template.is_a?(Class)
|
|
43
44
|
template.new(options)
|
|
44
45
|
elsif template.is_a?(String)
|
|
@@ -53,7 +54,7 @@ module Lumberjack
|
|
|
53
54
|
#
|
|
54
55
|
# @return [Array<Symbol>] An array of all registered log template symbols.
|
|
55
56
|
def registered_templates
|
|
56
|
-
@templates.dup
|
|
57
|
+
@lock.synchronize { @templates.dup }
|
|
57
58
|
end
|
|
58
59
|
end
|
|
59
60
|
end
|
data/lib/lumberjack/utils.rb
CHANGED
|
@@ -16,7 +16,7 @@ module Lumberjack
|
|
|
16
16
|
private_constant :NON_SLUGGABLE_PATTERN
|
|
17
17
|
|
|
18
18
|
@deprecations = nil
|
|
19
|
-
@deprecations_lock =
|
|
19
|
+
@deprecations_lock = Mutex.new
|
|
20
20
|
@hostname = UNDEFINED
|
|
21
21
|
|
|
22
22
|
class << self
|
|
@@ -39,7 +39,6 @@ module Lumberjack
|
|
|
39
39
|
# end
|
|
40
40
|
def deprecated(method, message)
|
|
41
41
|
if Lumberjack.deprecation_mode != :silent && !@deprecations&.include?(method)
|
|
42
|
-
@deprecations_lock ||= Mutex.new
|
|
43
42
|
@deprecations_lock.synchronize do
|
|
44
43
|
@deprecations ||= {}
|
|
45
44
|
unless @deprecations.include?(method)
|
|
@@ -209,18 +208,6 @@ module Lumberjack
|
|
|
209
208
|
flatten_hash_recursive(attr_hash)
|
|
210
209
|
end
|
|
211
210
|
|
|
212
|
-
# Alias for {.flatten_attributes} to provide compatibility with the 1.x API.
|
|
213
|
-
# This method will eventually be removed in a future version.
|
|
214
|
-
#
|
|
215
|
-
# @param tag_hash [Hash] The hash to flatten.
|
|
216
|
-
# @return [Hash<String, Object>] The flattened hash.
|
|
217
|
-
# @deprecated Use {.flatten_attributes} instead.
|
|
218
|
-
def flatten_tags(tag_hash)
|
|
219
|
-
Utils.deprecated("Lumberjack::Utils.flatten_tags", "Lumberjack::Utils.flatten_tags is deprecated and will be removed in version 2.1; use flatten_attributes instead.") do
|
|
220
|
-
flatten_attributes(tag_hash)
|
|
221
|
-
end
|
|
222
|
-
end
|
|
223
|
-
|
|
224
211
|
# Expand a hash containing dot notation keys into a nested hash structure.
|
|
225
212
|
# This is the inverse operation of {.flatten_attributes} and is useful for converting
|
|
226
213
|
# flat attribute structures back into nested hashes.
|
|
@@ -248,18 +235,6 @@ module Lumberjack
|
|
|
248
235
|
expand_dot_notation_hash(attributes)
|
|
249
236
|
end
|
|
250
237
|
|
|
251
|
-
# Alias for {.expand_attributes} to provide compatibility with the 1.x API.
|
|
252
|
-
# This method will eventually be removed in a future version.
|
|
253
|
-
#
|
|
254
|
-
# @param tags [Hash] The hash to expand.
|
|
255
|
-
# @return [Hash] The expanded hash.
|
|
256
|
-
# @deprecated Use {.expand_attributes} instead.
|
|
257
|
-
def expand_tags(tags)
|
|
258
|
-
Utils.deprecated("Lumberjack::Utils.expand_tags", "Lumberjack::Utils.expand_tags is deprecated and will be removed in version 2.1; use expand_attributes instead.") do
|
|
259
|
-
expand_attributes(tags)
|
|
260
|
-
end
|
|
261
|
-
end
|
|
262
|
-
|
|
263
238
|
private
|
|
264
239
|
|
|
265
240
|
# Recursively flatten a hash, building dot notation keys for nested structures.
|
data/lib/lumberjack.rb
CHANGED
|
@@ -59,19 +59,14 @@ module Lumberjack
|
|
|
59
59
|
require_relative "lumberjack/template"
|
|
60
60
|
require_relative "lumberjack/utils"
|
|
61
61
|
|
|
62
|
-
# Deprecated
|
|
63
|
-
require_relative "lumberjack/tag_context"
|
|
64
|
-
require_relative "lumberjack/tag_formatter"
|
|
65
|
-
require_relative "lumberjack/tags"
|
|
66
|
-
|
|
67
|
-
@global_contexts = {}
|
|
68
|
-
@global_contexts_mutex = Mutex.new
|
|
69
62
|
@deprecation_mode = nil
|
|
70
63
|
@raise_logger_errors = false
|
|
71
64
|
@isolation_level = :fiber
|
|
72
65
|
|
|
73
66
|
extend ContextLocals
|
|
74
67
|
|
|
68
|
+
init_context_locals!
|
|
69
|
+
|
|
75
70
|
class << self
|
|
76
71
|
# Contexts can be used to store attributes that will be attached to all log entries in the block.
|
|
77
72
|
# The context will apply to all Lumberjack loggers that are used within the block.
|
|
@@ -86,7 +81,9 @@ module Lumberjack
|
|
|
86
81
|
# @return [Object] The result
|
|
87
82
|
# of the block
|
|
88
83
|
def context(&block)
|
|
89
|
-
|
|
84
|
+
return current_context || Context.new unless block
|
|
85
|
+
|
|
86
|
+
use_context(current_context, &block)
|
|
90
87
|
end
|
|
91
88
|
|
|
92
89
|
# Ensure that the block of code is wrapped by a global context. If there is not already
|
|
@@ -126,12 +123,6 @@ module Lumberjack
|
|
|
126
123
|
!current_context.nil?
|
|
127
124
|
end
|
|
128
125
|
|
|
129
|
-
def context?
|
|
130
|
-
Utils.deprecated("Lumberjack.context?", "Lumberjack.context? is deprecated and will be removed in version 2.1; use in_context? instead.") do
|
|
131
|
-
in_context?
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
|
|
135
126
|
# Return attributes that will be applied to all Lumberjack loggers.
|
|
136
127
|
#
|
|
137
128
|
# @return [Hash, nil]
|
|
@@ -152,17 +143,6 @@ module Lumberjack
|
|
|
152
143
|
# @return [Symbol] The current isolation level.
|
|
153
144
|
attr_reader :isolation_level
|
|
154
145
|
|
|
155
|
-
# Alias for context_attributes to provide API compatibility with version 1.x.
|
|
156
|
-
# This method will eventually be removed.
|
|
157
|
-
#
|
|
158
|
-
# @return [Hash, nil]
|
|
159
|
-
# @deprecated Use {.context_attributes}
|
|
160
|
-
def context_tags
|
|
161
|
-
Utils.deprecated("Lumberjack.context_tags", "Lumberjack.context_tags is deprecated and will be removed in version 2.1; use context_attributes instead.") do
|
|
162
|
-
context_attributes
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
|
|
166
146
|
# Tag all loggers with attributes on the current context.
|
|
167
147
|
#
|
|
168
148
|
# @param attributes [Hash] The attributes to set.
|
data/lumberjack.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lumberjack
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brian Durand
|
|
@@ -23,20 +23,6 @@ dependencies:
|
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '0'
|
|
26
|
-
- !ruby/object:Gem::Dependency
|
|
27
|
-
name: bundler
|
|
28
|
-
requirement: !ruby/object:Gem::Requirement
|
|
29
|
-
requirements:
|
|
30
|
-
- - ">="
|
|
31
|
-
- !ruby/object:Gem::Version
|
|
32
|
-
version: '0'
|
|
33
|
-
type: :development
|
|
34
|
-
prerelease: false
|
|
35
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
-
requirements:
|
|
37
|
-
- - ">="
|
|
38
|
-
- !ruby/object:Gem::Version
|
|
39
|
-
version: '0'
|
|
40
26
|
email:
|
|
41
27
|
- bbdurand@gmail.com
|
|
42
28
|
executables: []
|
|
@@ -57,12 +43,10 @@ files:
|
|
|
57
43
|
- lib/lumberjack/context_logger.rb
|
|
58
44
|
- lib/lumberjack/device.rb
|
|
59
45
|
- lib/lumberjack/device/buffer.rb
|
|
60
|
-
- lib/lumberjack/device/date_rolling_log_file.rb
|
|
61
46
|
- lib/lumberjack/device/log_file.rb
|
|
62
47
|
- lib/lumberjack/device/logger_wrapper.rb
|
|
63
48
|
- lib/lumberjack/device/multi.rb
|
|
64
49
|
- lib/lumberjack/device/null.rb
|
|
65
|
-
- lib/lumberjack/device/size_rolling_log_file.rb
|
|
66
50
|
- lib/lumberjack/device/test.rb
|
|
67
51
|
- lib/lumberjack/device/writer.rb
|
|
68
52
|
- lib/lumberjack/device_registry.rb
|
|
@@ -81,7 +65,6 @@ files:
|
|
|
81
65
|
- lib/lumberjack/formatter/string_formatter.rb
|
|
82
66
|
- lib/lumberjack/formatter/strip_formatter.rb
|
|
83
67
|
- lib/lumberjack/formatter/structured_formatter.rb
|
|
84
|
-
- lib/lumberjack/formatter/tagged_message.rb
|
|
85
68
|
- lib/lumberjack/formatter/tags_formatter.rb
|
|
86
69
|
- lib/lumberjack/formatter/truncate_formatter.rb
|
|
87
70
|
- lib/lumberjack/formatter_registry.rb
|
|
@@ -89,6 +72,7 @@ files:
|
|
|
89
72
|
- lib/lumberjack/local_log_template.rb
|
|
90
73
|
- lib/lumberjack/log_entry.rb
|
|
91
74
|
- lib/lumberjack/log_entry_matcher.rb
|
|
75
|
+
- lib/lumberjack/log_entry_matcher/indifferent_hash.rb
|
|
92
76
|
- lib/lumberjack/log_entry_matcher/score.rb
|
|
93
77
|
- lib/lumberjack/logger.rb
|
|
94
78
|
- lib/lumberjack/message_attributes.rb
|
|
@@ -96,9 +80,6 @@ files:
|
|
|
96
80
|
- lib/lumberjack/rack/context.rb
|
|
97
81
|
- lib/lumberjack/remap_attribute.rb
|
|
98
82
|
- lib/lumberjack/severity.rb
|
|
99
|
-
- lib/lumberjack/tag_context.rb
|
|
100
|
-
- lib/lumberjack/tag_formatter.rb
|
|
101
|
-
- lib/lumberjack/tags.rb
|
|
102
83
|
- lib/lumberjack/template.rb
|
|
103
84
|
- lib/lumberjack/template_registry.rb
|
|
104
85
|
- lib/lumberjack/utils.rb
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "date"
|
|
4
|
-
|
|
5
|
-
module Lumberjack
|
|
6
|
-
# Deprecated device. Use LogFile instead.
|
|
7
|
-
#
|
|
8
|
-
# @deprecated Use Lumberjack::Device::LogFile
|
|
9
|
-
class Device::DateRollingLogFile < Device::LogFile
|
|
10
|
-
def initialize(path, options = {})
|
|
11
|
-
Utils.deprecated("Lumberjack::Device::DateRollingLogFile", "Lumberjack::Device::DateRollingLogFile is deprecated and will be removed in version 2.1; use Lumberjack::Device::LogFile instead.")
|
|
12
|
-
|
|
13
|
-
unless options[:roll]&.to_s&.match(/(daily)|(weekly)|(monthly)/i)
|
|
14
|
-
raise ArgumentError.new("illegal value for :roll (#{options[:roll].inspect})")
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
new_options = options.reject { |k, _| k == :roll }.merge(shift_age: options[:roll].to_s.downcase)
|
|
18
|
-
|
|
19
|
-
super(path, new_options)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lumberjack
|
|
4
|
-
# Deprecated device. Use LogFile instead.
|
|
5
|
-
#
|
|
6
|
-
# @deprecated Use Lumberjack::Device::LogFile
|
|
7
|
-
class Device::SizeRollingLogFile < Device::LogFile
|
|
8
|
-
attr_reader :max_size
|
|
9
|
-
|
|
10
|
-
# Create an new log device to the specified file. The maximum size of the log file is specified with
|
|
11
|
-
# the :max_size option. The unit can also be specified: "32K", "100M", "2G" are all valid.
|
|
12
|
-
def initialize(path, options = {})
|
|
13
|
-
Utils.deprecated("Lumberjack::Device::SizeRollingLogFile", "Lumberjack::Device::SizeRollingLogFile is deprecated and will be removed in version 2.1; use Lumberjack::Device::LogFile instead.")
|
|
14
|
-
|
|
15
|
-
@max_size = options[:max_size]
|
|
16
|
-
new_options = options.reject { |k, _| k == :max_size }.merge(shift_size: max_size)
|
|
17
|
-
new_options[:shift_age] = 10 unless options[:shift_age].is_a?(Integer) && options[:shift_age] >= 0
|
|
18
|
-
|
|
19
|
-
super(path, new_options)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "../message_attributes"
|
|
4
|
-
|
|
5
|
-
module Lumberjack
|
|
6
|
-
# This is a deprecated alias for Lumberjack::MessageAttributes.
|
|
7
|
-
#
|
|
8
|
-
# @deprecated Use Lumberjack::MessageAttributes instead.
|
|
9
|
-
# @see MessageAttributes
|
|
10
|
-
class Formatter::TaggedMessage < MessageAttributes
|
|
11
|
-
def initialize(message, attributes)
|
|
12
|
-
Utils.deprecated("Lumberjack::Formatter::TaggedMessage", "Use Lumberjack::MessageAttributes instead.") do
|
|
13
|
-
super
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lumberjack
|
|
4
|
-
# This class was renamed to Lumberjack::AttributesHelper. This class is provided for
|
|
5
|
-
# backward compatibility with the version 1.x API and will eventually be removed.
|
|
6
|
-
#
|
|
7
|
-
# @deprecated Use Lumberjack::AttributesHelper instead.
|
|
8
|
-
class TagContext < AttributesHelper
|
|
9
|
-
def initialize
|
|
10
|
-
Utils.deprecated("Lumberjack::TagContext", "Use Lumberjack::AttributesHelper instead.") do
|
|
11
|
-
super
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lumberjack
|
|
4
|
-
# TagFormatter has been renamed to {AttributeFormatter} as part of the transition from
|
|
5
|
-
# "tags" to "attributes" terminology in Lumberjack 2.0. This class exists solely for
|
|
6
|
-
# backward compatibility with the 1.x API and will be removed in a future version.
|
|
7
|
-
#
|
|
8
|
-
# All functionality has been moved to {AttributeFormatter} with no changes to the API.
|
|
9
|
-
# Simply replace +TagFormatter+ with +AttributeFormatter+ in your code.
|
|
10
|
-
#
|
|
11
|
-
# @deprecated Use {Lumberjack::AttributeFormatter} instead.
|
|
12
|
-
# @see Lumberjack::AttributeFormatter
|
|
13
|
-
#
|
|
14
|
-
# @example Migration
|
|
15
|
-
# # Old code (deprecated)
|
|
16
|
-
# formatter = Lumberjack::TagFormatter.new
|
|
17
|
-
#
|
|
18
|
-
# # New code
|
|
19
|
-
# formatter = Lumberjack::AttributeFormatter.new
|
|
20
|
-
class TagFormatter < AttributeFormatter
|
|
21
|
-
# Create a new TagFormatter instance. Issues a deprecation warning and delegates
|
|
22
|
-
# to {AttributeFormatter}.
|
|
23
|
-
#
|
|
24
|
-
# @deprecated Use {Lumberjack::AttributeFormatter.new} instead.
|
|
25
|
-
def initialize
|
|
26
|
-
Utils.deprecated("Lumberjack::TagFormatter", "Use Lumberjack::AttributeFormatter instead.") do
|
|
27
|
-
super
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
data/lib/lumberjack/tags.rb
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Lumberjack
|
|
4
|
-
class Tags
|
|
5
|
-
class << self
|
|
6
|
-
# Transform hash keys to strings. This method exists for optimization and backward compatibility.
|
|
7
|
-
# If a hash already has string keys, it will be returned as is.
|
|
8
|
-
#
|
|
9
|
-
# @param hash [Hash] The hash to transform.
|
|
10
|
-
# @return [Hash] The hash with string keys.
|
|
11
|
-
# @deprecated No longer supported
|
|
12
|
-
def stringify_keys(hash)
|
|
13
|
-
Utils.deprecated("Lumberjack::Tags.stringify_keys", "Lumberjack::Tags.stringify_keys is no longer supported and will be removed in version 2.1") do
|
|
14
|
-
return nil if hash.nil?
|
|
15
|
-
|
|
16
|
-
if hash.keys.all? { |key| key.is_a?(String) }
|
|
17
|
-
hash
|
|
18
|
-
else
|
|
19
|
-
hash.transform_keys(&:to_s)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# Alias to AttributesHelper.expand_runtime_values
|
|
25
|
-
#
|
|
26
|
-
# @param hash [Hash] The hash to transform.
|
|
27
|
-
# @return [Hash] The hash with string keys and expanded values.
|
|
28
|
-
# @deprecated Use {Lumberjack::AttributesHelper.expand_runtime_values} instead.
|
|
29
|
-
def expand_runtime_values(hash)
|
|
30
|
-
Utils.deprecated("Lumberjack::Tags.expand_runtime_values", "Lumberjack::Tags.expand_runtime_values is deprecated and will be removed in version 2.1; use Lumberjack::AttributesHelper.expand_runtime_values instead.") do
|
|
31
|
-
AttributesHelper.expand_runtime_values(hash)
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|