Class: Ama::Logger::Formatter::Lambda

Inherits:
Object
  • Object
show all
Defined in:
lib/ama/logger/formatter/lambda.rb

Instance Method Summary collapse

Instance Method Details

#call(severity, time, _progname, msg = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ama/logger/formatter/lambda.rb', line 7

def call(severity, time, _progname, msg = {})
  invalid_argument!(:msg, Hash, msg) unless msg.is_a?(Hash)

  context = msg.fetch(:context) { missing_argument!(:context) }
  event_name = msg.fetch(:event_name) { missing_argument!(:event_name) }

  {
    exception: msg[:exception],
    eventName: event_name,
    eventSource: context.invoked_function_arn,
    eventId: context.aws_request_id,
    eventAgent: Ama::Logger::AGENT_VERSION,
    details: details(msg),
    indexed: indexed(msg),
    severity: severity,
    timestamp: time.utc.iso8601
  }
    .compact
    .to_json
    .concat("\n")
end