mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-24 01:31:55 +00:00
Implement rate limiting on log messages
Addresses issue #317, where logs can get spammed with the same message nonstop. Created a rate limiting closure on logging functions, which limits the number of messages being logged per second based on format string. Signed-off-by: Wendi Yu <wendi.yu@yahoo.ca>
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"tailscale.com/control/controlclient"
|
||||
"tailscale.com/tailcfg"
|
||||
"tailscale.com/tstest"
|
||||
"tailscale.com/types/logger"
|
||||
"tailscale.com/wgengine"
|
||||
"tailscale.com/wgengine/magicsock"
|
||||
"tailscale.com/wgengine/router"
|
||||
@@ -191,12 +192,16 @@ type testNode struct {
|
||||
// Create a new IPN node.
|
||||
func newNode(t *testing.T, prefix string, https *httptest.Server, weirdPrefs bool) testNode {
|
||||
t.Helper()
|
||||
logfe := func(fmt string, args ...interface{}) {
|
||||
|
||||
ulogfe := func(fmt string, args ...interface{}) {
|
||||
t.Logf(prefix+".e: "+fmt, args...)
|
||||
}
|
||||
logf := func(fmt string, args ...interface{}) {
|
||||
logfe := logger.RateLimitedFn(ulogfe, 1, 1)
|
||||
|
||||
ulogf := func(fmt string, args ...interface{}) {
|
||||
t.Logf(prefix+": "+fmt, args...)
|
||||
}
|
||||
logf := logger.RateLimitedFn(ulogf, 1, 1)
|
||||
|
||||
var err error
|
||||
httpc := https.Client()
|
||||
|
||||
Reference in New Issue
Block a user