15397: Silence nginx log noise like "closed keepalive connection".
[arvados.git] / lib / dispatchcloud / logger.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 package dispatchcloud
6
7 import (
8         "sync"
9         "time"
10 )
11
12 type logger interface {
13         Printf(string, ...interface{})
14         Warnf(string, ...interface{})
15         Debugf(string, ...interface{})
16 }
17
18 var nextSpam = map[string]time.Time{}
19 var nextSpamMtx sync.Mutex
20
21 func unspam(msg string) bool {
22         nextSpamMtx.Lock()
23         defer nextSpamMtx.Unlock()
24         if nextSpam[msg].Before(time.Now()) {
25                 nextSpam[msg] = time.Now().Add(time.Minute)
26                 return true
27         }
28         return false
29 }