axios-logger icon indicating copy to clipboard operation
axios-logger copied to clipboard

Add body trimming

Open Fylipp opened this issue 5 years ago • 6 comments

When logging the bodies of large requests or responses it would make sense to allow them to be limited to a certain size. Otherwise large bodies clutter the console without adding value.

Fylipp avatar Mar 19 '20 11:03 Fylipp

Great idea. But I think It can be controlled by axios maxContentLength property. This part looks good to delegate to axios.

hg-pyun avatar Mar 19 '20 12:03 hg-pyun

The problem is that an application might need the entire response. For my use case I expect to receive multiple kilobytes of text data and it all has to be processed, meaning I need Axios to properly treat the response (ruling out maxContentLength). However, this fills up the logs with lots of clutter from the logging. Being able to only the log the first 100 characters or so would allow logging to be used with large responses.

Fylipp avatar Mar 20 '20 23:03 Fylipp

Oh, I see. You means that It need to limit for only log data. I will consider. Thank you for feedback.

hg-pyun avatar Mar 21 '20 03:03 hg-pyun

👍 this would be very helpful

giogonzo avatar Nov 12 '21 17:11 giogonzo

https://github.com/hg-pyun/axios-logger/pull/129

richardscholten avatar May 16 '23 08:05 richardscholten