How to automatically save in separate files?

New to mitmproxy, got a basic regular proxy working.

I want to automatically (non-interactively) save all requests with the request/headers in one file, the response headers in another, and the response body in another, and I’m a bit overwhelmed and unsure how to even begin.