-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http: ErrorLog not generic enough to get at the net.Conn info for errors #15949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Something like: |
Would this generalize to a feature request for better tracing hooks on http.Server, similar to the client-side hooks added for go 1.7? Probably related to #3344 (comment) |
If tracing hooks on http.Server are created then yes but might be overkill as to me, just calling the Logger with an English error message on errors is not a great design for a standard library as it leaves no options for translations or any deep dive into the net.Conn that errored out and simply adding a "real" handler that takes arguments like the Err code and the net.Conn so as not to break compatibility is all that is needed to fix this. |
Tracing hooks are already implemented for 1.7. The link above is to the current 1.7 docs. Please take a look at those docs, or try the 1.7 beta, and see if it addresses your need. |
No, it does not. I am trying to get the ErrorLog handler to be more generic - basically the error logs that server.go:2259 is throwing are useless as they are in English and have no way to pass along the net.Conn that caused the issue nor an Error code that could be used to generate a localized string in the logs. My suggestion is to actually have an ErrorHandler(net.Conn, error, ...interface{}) that is called if set, and the current processing done only if the ErrorHandler isn't set. Basically, the ErrorLog interface is flawed, and I am suggesting a workaround to not break current compatibility. I want to know about the errors and want to be able to look at the net.Conn's TLS ConnectionState() and find the SNI for example to generate more informational logs and ErrorLog cannot do that. |
I'm not a fan of this proposal:
In addition to the unclarity around the I'd review a more formal proposal around structured error handling in the I'd want to see an audit of all uses of ErrorLog and how what each call site should do instead to provide more context around the error, providing a rich error type. Is anybody interested in writing a proposal? |
Timeout. |
Please answer these questions before submitting your issue. Thanks!
go version
)?go1.6.2
go env
)?GOARCH="amd64"
GOOS="linux"
Intentionally made TLS handshake fail, got log to standard out. Wanted to get ConnectionState() of the c.rwc to get the SNI but there is no way to get at it.
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
Better error handling in server.go using an ErrorHandler interface that gets a net.Conn and an error as arguments (in addition to a ...interface{} for additional arguments that might be useful) rather than the call to logf that uses log.Logger.
English log line that doesn't have anything related to the connection in it and no possibility of using translations, or looking into the ConnectionState() tls SNI.
The text was updated successfully, but these errors were encountered: