10
11
12
13
14
15
16
17
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/openc3/utilities/cosmos_rails_formatter.rb', line 10
def call(log, _appender = nil)
message = log.message
other = {}
other[:thread_name] = log.thread_name
other[:duration] = log.duration if log.duration
named_tags = log.named_tags
username = nil
if named_tags
other[:request_id] = named_tags[:request_id]
if named_tags[:token]
begin
user = user_info(named_tags[:token])
rescue
user = {}
end
username = user['username']
username ||= 'anonymous'
end
end
username ||= 'anonymous'
payload = log.payload
if payload
other[:path] = payload[:path]
other[:status] = payload[:status]
other[:controller] = payload[:controller]
other[:action] = payload[:action]
other[:format] = payload[:format]
other[:method] = payload[:method]
other[:allocations] = payload[:allocations]
other[:view_runtime] = payload[:view_runtime]
if payload[:exception_object]
other[:exception_message] = payload[:exception_object].message
other[:exception_class] = payload[:exception_object].class.to_s
other[:exception_backtrace] = payload[:exception_object].backtrace.as_json
end
end
if log.exception
message = "Exception was raised - #{log.exception.class}:#{log.exception.message}" unless message
end
return OpenC3::Logger.build_log_data(log.level.to_s.upcase, message, user: username, type: OpenC3::Logger::LOG, url: nil, other: other).as_json(:allow_nan => true).to_json(:allow_nan => true)
end
|