33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/vagrant/util/logging_formatter.rb', line 33
def format(event)
message = format_object(event.data).
force_encoding('UTF-8').
scrub("?")
if message.length > MAX_MESSAGE_LENGTH
message = Array.new.tap { |a|
until message.empty?
a << "continued..." unless a.empty?
a << message.slice!(0, MAX_MESSAGE_LENGTH)
end
}
else
message = [message]
end
message.map do |msg|
d = {
"@timestamp" => Time.now.strftime("%Y-%m-%dT%H:%M:%S.%6N%:z"),
"@level" => Log4r::LNAMES[event.level].downcase,
"@module" => event.fullname,
"@name" => event.name,
"@message" => msg,
}
d["@caller"] = event.tracer[0] if event.tracer
d.to_json + "\n"
end
end
|