diff --git a/Gopkg.lock b/Gopkg.lock index 0f14eabc..c49c2bdf 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -77,10 +77,10 @@ revision = "0fb14efe8c47ae851c0034ed7a448854d3d34cf3" [[projects]] + branch = "master" name = "github.com/jedisct1/dlog" packages = ["."] - revision = "2318da0182ccf19c77f0dab8a97c5eacd111cb84" - version = "0.2" + revision = "9025b39d3d9a4e268e01f536c71c6177518fc461" [[projects]] branch = "master" diff --git a/vendor/github.com/jedisct1/dlog/Gopkg.lock b/vendor/github.com/jedisct1/dlog/Gopkg.lock index e0067660..92f92a1d 100644 --- a/vendor/github.com/jedisct1/dlog/Gopkg.lock +++ b/vendor/github.com/jedisct1/dlog/Gopkg.lock @@ -15,11 +15,11 @@ "windows/registry", "windows/svc/eventlog" ] - revision = "2c42eef0765b9837fbdab12011af7830f55f88f0" + revision = "37707fdb30a5b38865cfb95e5aab41707daec7fd" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "7dd24393da8db7d16249fa8f14426fb6418a2cefca2045da212cf4f299a5a1f0" + inputs-digest = "328c0e201a8f9b84770fc7b0efb002f50e64da384499776e57cc1edb38b26a51" solver-name = "gps-cdcl" solver-version = 1 diff --git a/vendor/github.com/jedisct1/dlog/Gopkg.toml b/vendor/github.com/jedisct1/dlog/Gopkg.toml index 0a0b3bef..3b1e4958 100644 --- a/vendor/github.com/jedisct1/dlog/Gopkg.toml +++ b/vendor/github.com/jedisct1/dlog/Gopkg.toml @@ -1,3 +1,7 @@ [[constraint]] branch = "master" name = "github.com/hashicorp/go-syslog" + +[[constraint]] + branch = "master" + name = "golang.org/x/sys" diff --git a/vendor/github.com/jedisct1/dlog/dlog.go b/vendor/github.com/jedisct1/dlog/dlog.go index 44e5de7f..e5e37943 100644 --- a/vendor/github.com/jedisct1/dlog/dlog.go +++ b/vendor/github.com/jedisct1/dlog/dlog.go @@ -22,12 +22,18 @@ type globals struct { systemLogger *systemLogger fileName *string outFd *os.File + lastMessage string + lastOccurrence time.Time + occurrences uint64 } var ( _globals = globals{ - logLevel: SeverityLast, - appName: "-", + logLevel: SeverityLast, + appName: "-", + lastMessage: "", + lastOccurrence: time.Now(), + occurrences: 0, } ) @@ -42,6 +48,11 @@ const ( SeverityLast ) +const ( + FloodDelay = 5 * time.Second + FloodMinRepeats = 3 +) + var SeverityName = []string{ SeverityDebug: "DEBUG", SeverityInfo: "INFO", @@ -183,6 +194,18 @@ func logf(severity Severity, format string, args ...interface{}) { } _globals.Lock() defer _globals.Unlock() + if _globals.lastMessage == message { + if time.Since(_globals.lastOccurrence) < FloodDelay { + _globals.occurrences++ + if _globals.occurrences > FloodMinRepeats { + return + } + } + } else { + _globals.occurrences = 0 + _globals.lastMessage = message + } + _globals.lastOccurrence = now if *_globals.useSyslog && _globals.systemLogger == nil { systemLogger, err := newSystemLogger(_globals.appName, _globals.syslogFacility) if err == nil {