Sha256: 0ac3c5003c68ddadf9c152bbe6b03f5830125638d7e41490262aecb2905e05a9

Contents?: true

Size: 850 Bytes

Versions: 4

Compression:

Stored size: 850 Bytes

Contents

module Dynamoid
  module Log
    module Formatter

      # https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Log/Formatter.html
      # https://docs.aws.amazon.com/sdk-for-ruby/v2/api/Seahorse/Client/Response.html
      # https://aws.amazon.com/ru/blogs/developer/logging-requests/
      class Debug
        def format(response)
          bold = "\x1b[1m"
          color = "\x1b[34m"
          reset = "\x1b[0m"

          [
            response.context.operation.name,
            "#{bold}#{color}\nRequest:\n#{reset}#{bold}",
            JSON.pretty_generate(JSON.parse(response.context.http_request.body.string)),
            "#{bold}#{color}\nResponse:\n#{reset}#{bold}",
            JSON.pretty_generate(JSON.parse(response.context.http_response.body.string)),
            reset
          ].join("\n")
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dynamoid-3.8.0 lib/dynamoid/log/formatter.rb
dynamoid-3.7.1 lib/dynamoid/log/formatter.rb
dynamoid-3.7.0 lib/dynamoid/log/formatter.rb
dynamoid-3.6.0 lib/dynamoid/log/formatter.rb