Obligatory disclaimer: I'm one of the mitmproxy authors - happy to answer any questions.
[1] https://mitmproxy.org/
[2] http://docs.mitmproxy.org/en/stable/dev/sslkeylogfile.html