leviysoft / mockingbird

Flexible mock server
Apache License 2.0
9 stars 3 forks source link

Proposal: add logging of request from proxy stub for debugging purposes. #13

Closed ashashev closed 11 months ago

ashashev commented 11 months ago

It's pretty hard to understand what request will be executed from mockingbird to a remote server, when stub works in proxy mode. The logging of requests simplifies understanding what happens. It's not necessary, but could be useful.

The PR add to the log the following records:

{"@timestamp":"2023-09-30T20:11:48.776Z","loggerName":"ru.tinkoff.tcb.mockingbird.api.PublicApiHandler","threadName":"ZScheduler-2","level":"DEBUG","message":"Executing request: curl \\\n  --request GET \\\n  --url 'https://catfact.ninja/fact' \\\n  --header 'Host: catfact.ninja' \\\n  --header 'User-Agent: curl/7.88.1' \\\n  --header 'Accept: */*' \\\n  --location \\\n  --max-redirs 32","correlationId":"ee779037-c036-465b-9ac8-46987bb3a7be","payload":{"path":"/alpha/fact","method":"GET","name":"cats fact"}}
danslapman commented 11 months ago

I think we should have a flag in settings for this (disabled by default)

ashashev commented 11 months ago

Add parameter to the config. Also, I forgot to add logging to stubs that expect response as JSON or XML. I added logging to it too.