Class: Webhookdb::AWS::ShimLogger
- Inherits:
-
Object
- Object
- Webhookdb::AWS::ShimLogger
- Defined in:
- lib/webhookdb/aws.rb
Instance Method Summary collapse
-
#initialize(logger, operation_prefix: "aws_", level: :debug, error_level: :warn) ⇒ ShimLogger
constructor
A new instance of ShimLogger.
-
#logshim(response) ⇒ Object
Logger method.
Constructor Details
#initialize(logger, operation_prefix: "aws_", level: :debug, error_level: :warn) ⇒ ShimLogger
Returns a new instance of ShimLogger.
15 16 17 18 19 20 21 22 |
# File 'lib/webhookdb/aws.rb', line 15 def initialize(logger, operation_prefix: "aws_", level: :debug, error_level: :warn) @logger = logger @param_formatter = ::Aws::Log::ParamFormatter.new({}) @param_filter = ::Aws::Log::ParamFilter.new({}) @operation_prefix = operation_prefix @level = level @error_level = error_level end |
Instance Method Details
#logshim(response) ⇒ Object
Logger method. Receives the unformatted response form the shim formatter, and logs a structured log.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/webhookdb/aws.rb', line 27 def logshim(response) level = @level msg = @operation_prefix + response.context.operation_name.to_s params = response.context.params type = response.context.operation.input.shape.struct_class ctx = { aws_client: (response.context.client.class.name || "").delete_prefix("Aws::").delete_suffix("::Client"), http_response_code: response.context.http_response.status_code, elapsed: response.context[:logging_completed_at] - response.context[:logging_started_at], request_params: @param_formatter.summarize(@param_filter.filter(params, type)), } ctx[:retries] = response.context.retries if response.context.retries.positive? if response.error level = @error_level ctx[:error_class] = response.error.class.name ctx[:error_message] = response.error. end @logger.send(level, msg, ctx) end |