samuong / alpaca

A local HTTP proxy for command-line tools. Supports PAC scripts and NTLM authentication.
Apache License 2.0
184 stars 31 forks source link

Log 407 responses from proxy #85

Closed samuong closed 2 years ago

samuong commented 2 years ago

When a proxy server responses with 407 Proxy Authentication Required, Alpaca silently retries the request with authentication. This PR adds logging so that we know when Alpaca has gone down the code path to authenticate to the proxy. This makes it easier to see what's going on in cases such as issue #44.

samhaque commented 2 years ago

I spoke with a few users who have requested to set verbosity on the log messages via some environment variable, as they said it's too noisy.

Also I believe when installed as a brew service the logs are sent to dev null, we can also look at piping the logs to a rotating log file.

samuong commented 2 years ago

@samhaque is it too noisy because of this change specifically, or is that more of a general comment?

I'm wondering if it would help to try to rework this PR so that it (usually, unless there's an error somewhere else) prints a single line per request (e.g. GET http://example.com via "DIRECT", retried with auth) rather than two separate lines.

samhaque commented 2 years ago

So users said noisy in general but that's just how a proxy works, I guess a switch to turn the logging off is what the users are looking for, as there is a performance cost to consider when logging every successful proxy request.

samuong commented 2 years ago

Ok, I'll land this as is then, and we can think about how to make it less verbose in a separate issue/pull request. Obviously it's easy enough to just redirect all output to /dev/null, but it would be good to get a better sense of what is still useful and what is noise.