lib/semantic_logger/base.rb in semantic_logger-4.10.0 vs lib/semantic_logger/base.rb in semantic_logger-4.11.0
- old
+ new
@@ -184,11 +184,12 @@
# However, this api will convert:
# `logger.tagged([['first', nil], nil, ['more'], 'other'])`
# to:
# `logger.tagged('first', 'more', 'other')`
# - For better performance with clean tags, see `SemanticLogger.tagged`.
- def tagged(*tags, &block)
+ def tagged(*tags)
+ block = -> { yield(self) }
# Allow named tags to be passed into the logger
# Rails::Rack::Logger passes logs as an array with a single argument
if tags.size == 1 && !tags.first.is_a?(Array)
tag = tags[0]
return yield if tag.nil? || tag == ""
@@ -325,17 +326,17 @@
payload = nil
end
log = Log.new(name, level, index)
should_log =
- if payload.nil? && exception.nil? && message.is_a?(Hash)
- # Everything as keyword arguments.
+ if exception.nil? && payload.nil? && message.is_a?(Hash)
+ # All arguments as a hash in the message.
log.assign(**log.extract_arguments(message))
elsif exception.nil? && message && payload && payload.is_a?(Hash)
- # Message with keyword arguments as the rest.
- log.assign(message: message, **log.extract_arguments(payload))
+ # Message supplied along with a hash with the remaining arguments.
+ log.assign(**log.extract_arguments(payload, message))
else
- # No keyword arguments.
+ # All fields supplied directly.
log.assign(message: message, payload: payload, exception: exception)
end
# Add result of block to message or payload if not nil
if block_given?