30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/log_struct/monkey_patches/active_support/tagged_logging/formatter.rb', line 30
def call(severity, time, progname, data)
return super unless ::LogStruct.enabled?
tags = T.unsafe(self).respond_to?(:current_tags) ? current_tags : (Thread.current[:activesupport_tagged_logging_tags] || [])
data_with_tags = if data.is_a?(Hash)
tags.present? ? data.merge(tags: tags) : data
elsif data.is_a?(::LogStruct::Log::Interfaces::CommonFields) || (data.is_a?(T::Struct) && data.respond_to?(:serialize))
hash = T.unsafe(data).serialize
tags.present? ? hash.merge(tags: tags) : hash
else
base = {LogStruct::LogField::Message.serialize => data.to_s}
tags.present? ? base.merge(tags: tags) : base
end
logstruct_formatter.call(severity, time, progname, data_with_tags)
end
|