18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/groonga-delta/ltsv-log-formatter.rb', line 18
def call(severity, time, program_name, message)
prefix = "timestamp:%{timestamp}\tseverity:%{severity}\tpid:%{pid}" % {
severity: severity,
timestamp: time.strftime("%Y-%m-%dT%H:%M:%S.%N"),
pid: Process.pid,
}
formatted = ""
backtrace = nil
case message
when String
when Exception
backtrace = message.backtrace
message = "#{message.class}: #{message}"
else
message = message.inspect
end
message.each_line(chomp: true) do |line, i|
formatted << "#{prefix}\tmessage:#{escape_value(line)}\n"
end
if backtrace
backtrace.each do |trace|
formatted << "#{prefix}\tmessage:#{escape_value(trace)}\n"
end
end
formatted
end
|