summaryrefslogtreecommitdiffhomepage
path: root/tsweb/tsweb.go
diff options
context:
space:
mode:
authorJoe Tsai <joetsai@digital-static.net>2022-08-01 15:25:56 -0700
committerJoe Tsai <joetsai@digital-static.net>2022-08-01 15:25:56 -0700
commitbc9d4ac8eaf4ae80cb10f57c1b06eca24cb39d44 (patch)
tree1a183fc8d661e8190faa0f35649cc364fc121514 /tsweb/tsweb.go
parent357fd85ecf41787231a621c26715b0de90c90b95 (diff)
downloadtailscale-dsnet/tsweb-499s.tar.xz
tailscale-dsnet/tsweb-499s.zip
tsweb: add HandlerOptions.Quiet499sdsnet/tsweb-499s
Client termination of a request is a fairly common situation where we may want to suppress logs for. The Quiet499s suppresses such logs similar to Quiet200s. Signed-off-by: Joe Tsai <joetsai@digital-static.net>
Diffstat (limited to 'tsweb/tsweb.go')
-rw-r--r--tsweb/tsweb.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/tsweb/tsweb.go b/tsweb/tsweb.go
index eb8ffb138..8a837eac8 100644
--- a/tsweb/tsweb.go
+++ b/tsweb/tsweb.go
@@ -186,6 +186,7 @@ type ReturnHandler interface {
type HandlerOptions struct {
Quiet200s bool // if set, do not log successfully handled HTTP requests
+ Quiet499s bool // if set, do not log client-canceled HTTP requests
Logf logger.Logf
Now func() time.Time // if nil, defaults to time.Now
@@ -310,7 +311,10 @@ func (h retHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}
- if msg.Code != 200 || !h.opts.Quiet200s {
+ switch {
+ case msg.Code == 200 && h.opts.Quiet200s:
+ case msg.Code == 499 && h.opts.Quiet499s:
+ default:
h.opts.Logf("%s", msg)
}