lib/chalk-log/layout.rb in chalk-log-0.1.5 vs lib/chalk-log/layout.rb in chalk-log-0.1.6
- old
+ new
@@ -48,10 +48,11 @@
time = event.time
level = event.level
# Data provided by blocks may not be arrays yet
data = [data] unless data.kind_of?(Array)
+ data = data.dup # Make a private copy that we can mutate
info = data.pop if data.last.kind_of?(Hash)
error = data.pop if data.last.kind_of?(Exception)
message = data.pop if data.last.kind_of?(String)
if data.length > 0
@@ -64,11 +65,11 @@
time: timestamp_prefix(time),
level: Chalk::Log::LEVELS[level],
span: span.to_s,
message: message,
error: error,
- info: (info && info.merge(contextual_info || {})) || contextual_info,
+ info: (info && (contextual_info || {}).merge(info)) || contextual_info,
pid: pid
)
end
def pretty_print(spec)
@@ -93,11 +94,11 @@
end
if info
message << ' ' if message
message ||= ''
- info!(message, info)
+ message << format_hash(info)
end
if error
message << ' ' if message
message ||= ''
@@ -105,15 +106,9 @@
end
message ||= ''
message << "\n"
message
- end
-
- # Displaying info hash
-
- def info!(message, info)
- message << format_hash(info.merge(contextual_info || {}))
end
def display(key, value)
begin
value = json(value)