diff --git a/logp/ratelimited.go b/logp/ratelimited.go index ff55d1f..e29cdc1 100644 --- a/logp/ratelimited.go +++ b/logp/ratelimited.go @@ -56,8 +56,7 @@ type RateLimitedLogger struct { // NewRateLimited returns a new RateLimitedLogger. It takes a logFn, which is // called with the count of events and the period between each call, // and a period determining how often the log function should be called. -func NewRateLimited( - logFn func(count uint64, d time.Duration), period time.Duration) *RateLimitedLogger { +func NewRateLimited(period time.Duration, logFn func(count uint64, d time.Duration)) *RateLimitedLogger { return &RateLimitedLogger{ period: period, logFn: logFn, diff --git a/logp/ratelimited_test.go b/logp/ratelimited_test.go index 39c2ad3..e96fb4d 100644 --- a/logp/ratelimited_test.go +++ b/logp/ratelimited_test.go @@ -65,7 +65,7 @@ func TestRateLimitedLogger(t *testing.T) { now := time.Now() t.Run("Start", func(t *testing.T) { - r := NewRateLimited(func(count uint64, d time.Duration) {}, math.MaxInt64) + r := NewRateLimited(math.MaxInt64, func(count uint64, d time.Duration) {}) defer r.Stop() r.nowFn = func() time.Time { return now } @@ -77,7 +77,7 @@ func TestRateLimitedLogger(t *testing.T) { }) t.Run("Start twice", func(t *testing.T) { - r := NewRateLimited(func(count uint64, d time.Duration) {}, math.MaxInt64) + r := NewRateLimited(math.MaxInt64, func(count uint64, d time.Duration) {}) defer r.Stop() r.nowFn = func() time.Time { return now } @@ -101,7 +101,7 @@ func TestRateLimitedLogger(t *testing.T) { for _, tc := range tcs { t.Run(tc.name, func(t *testing.T) { buff, logFn := newLogger() - r := NewRateLimited(logFn, 42*time.Second) + r := NewRateLimited(42*time.Second, logFn) r.nowFn = func() time.Time { return now } tch := make(chan time.Time) @@ -134,7 +134,7 @@ func TestRateLimitedLogger(t *testing.T) { t.Run("Add", func(t *testing.T) { buff, logFn := newLogger() - r := NewRateLimited(logFn, 42*time.Second) + r := NewRateLimited(42*time.Second, logFn) defer r.Stop() r.nowFn = func() time.Time { return now } @@ -164,7 +164,7 @@ func TestRateLimitedLogger(t *testing.T) { t.Run("AddN", func(t *testing.T) { buff, logFn := newLogger() - r := NewRateLimited(logFn, 42*time.Second) + r := NewRateLimited(42*time.Second, logFn) defer r.Stop() r.nowFn = func() time.Time { return now }