req icon indicating copy to clipboard operation
req copied to clipboard

New step: Log request/response

Open wojtekmach opened this issue 1 year ago • 8 comments

TBD the naming and output formatting but basically we want to dump the raw request and response for debugging. Something like this:

image

It's using logger so that users can enable this in tests but also set @tag :capture_log, i.e. see this only when the tests fail.

HTTPie has interesting options for output formatting:

  --print WHAT, -p WHAT
      String specifying what the output should contain:

          'H' request headers
          'B' request body
          'h' response headers
          'b' response body
          'm' response metadata

      The default behaviour is 'hb' (i.e., the response
      headers and body is printed), if standard output is not redirected.
      If the output is piped to another program or to a file, then only the
      response body is printed by default.

so we might look into something like that too. Or, we double-down on logger and expose variables to be used by formatting configuration:

"\n$time $metadata[$level] $message\n"

cc @reisub

wojtekmach avatar Sep 18 '23 08:09 wojtekmach