zapier / zapier-platform

The SDK for you to build an integration on Zapier

Home Page:https://platform.zapier.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make it possible to view logs locally from zapier test

GibsDev opened this issue · comments

Current Behavior

zapier logs only shows logs from the server

Desired Behavior

Zapier CLI can record logs locally when using zapier test
zapier logs has a flag (something like -l, --local) to view local logs

Reason

This would be especially helpful for debugging http requests. It is possible to use the -d for zapier test to view http requests, but it gets intermingled with lots of other data.

An alternative solution would be to specify what gets outputted by the -d flag when using zapier test

Because logs from local unit tests aren't sent to the server at all, we won't be able to plug them into zapier logs.

But, you can log your own requests. Instead of using --debug, try this:

LOG_TO_STDOUT=1 DETAILED_LOG_TO_STDOUT=1 zapier test

That'll log super detailed request data to the console:

console.log
      GET https://auth-json-server.zapier-staging.com/me?api_key=secret
      user-agent: Zapier



      200

      access-control-allow-credentials: true
      cache-control: no-cache
      connection: close
      content-encoding: gzip
      content-type: application/json; charset=utf-8
      date: Wed, 03 Nov 2021 23:20:49 GMT
      etag: W/"1fd-+2Y3G3w049iSZtw5t1mzSnunngE"
      expires: -1
      pragma: no-cache
      strict-transport-security: max-age=15724800; includeSubDomains
      transfer-encoding: chunked
      vary: Accept-Encoding, Origin, Accept-Encoding
      x-content-type-options: nosniff
      x-powered-by: Express

      {
        "id": 1,
        "name": "Leanne Graham",
        "username": "Bret",
        "email": "Sincere@april.biz",
        "address": {
          "street": "Kulas Light",
          "suite": "Apt. 556",
          "city": "Gwenborough",
          "zipcode": "92998-3874",
          "geo": {
            "lat": "-37.3159",
            "lng": "81.1496"
          }
        },
        "phone": "1-770-736-8031 x56442",
        "website": "hildegard.org",
        "company": {
          "name": "Romaguera-Crona",
          "catchPhrase": "Multi-layered client-server neural-net",
          "bs": "harness real-time e-markets"
        }
      }

      at toStdout (../../platform/packages/core/src/tools/create-logger.js:99:15)

I'm not positive that's documented (I usually debug with regular console.log), but it should help here!

If not, tell us more about what data you're missing when debugging and we can see about adding it!

Thank you for the insight! I will keep this saved for the next time I'm trying to debug HTTP requests