Let's have the ability to save HTTP logs to disk, by default.
Acceptance Criteria
- All HTTP requests and response should be saved in the profile directory.
epcc logs list should list all HTTP requests made.
- Each line should list
<N> <METHOD> <QUERY_STRING> ==> RESPONSE STATUS, where N is an increasing number.
- An example would be
4 POST /v2/customers ==> HTTP/1.1 201
- The requests should be in order of oldest request to newest request (last).
epcc logs show <N> should show the full request and response for line n.
epcc logs clear should delete all the requests in the profile directory.
💡 To implement this ticket, I recommend the following tips:
- The EPCC Terraform Provider project has a log to disk function, and has the hooks necessary to get the request and response. We stole and adapted our HTTP client from there, so you should able to steal that code and put it in here. https://github.com/elasticpath/terraform-provider-epcc/blob/main/external/sdk/epcc/client.go#L264
- Generating the list could be expensive, if you have to open each file in the profile and parse it. Instead what we could do is when you save the file to disk you could just save the file with the file name of " ==> RESPONSE STATUS", however some of those characters are not safe for the file system and super annoying, so we can just Base64URLEncode the string. For example using https://base64.guru/standards/base64url/encode , we can see that the base64 encoded version of "POST /v2/customers ==> HTTP/1.1 201" is UE9TVCAvdjIvY3VzdG9tZXJzID09PiBIVFRQLzEuMSAyMDE" , so we use that as a file name (with a .txt suffix), and then to generate the list you simply list all the files sorted by create time, and then base64url decode the name.
- Let's use sub commands under logs for auto complete, instead of implementing , , manually. This will help because we will want to have other things later, and should simplify the code.
Let's have the ability to save HTTP logs to disk, by default.
Acceptance Criteria
epcc logs listshould list all HTTP requests made.<N> <METHOD> <QUERY_STRING> ==> RESPONSE STATUS, where N is an increasing number.4 POST /v2/customers ==> HTTP/1.1 201epcc logs show <N>should show the full request and response for line n.epcc logs clearshould delete all the requests in the profile directory.💡 To implement this ticket, I recommend the following tips: