Update dlog
This commit is contained in:
parent
404c21816e
commit
6863ab66d5
|
@ -77,10 +77,10 @@
|
||||||
revision = "0fb14efe8c47ae851c0034ed7a448854d3d34cf3"
|
revision = "0fb14efe8c47ae851c0034ed7a448854d3d34cf3"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
name = "github.com/jedisct1/dlog"
|
name = "github.com/jedisct1/dlog"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "2318da0182ccf19c77f0dab8a97c5eacd111cb84"
|
revision = "9025b39d3d9a4e268e01f536c71c6177518fc461"
|
||||||
version = "0.2"
|
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
|
|
@ -15,11 +15,11 @@
|
||||||
"windows/registry",
|
"windows/registry",
|
||||||
"windows/svc/eventlog"
|
"windows/svc/eventlog"
|
||||||
]
|
]
|
||||||
revision = "2c42eef0765b9837fbdab12011af7830f55f88f0"
|
revision = "37707fdb30a5b38865cfb95e5aab41707daec7fd"
|
||||||
|
|
||||||
[solve-meta]
|
[solve-meta]
|
||||||
analyzer-name = "dep"
|
analyzer-name = "dep"
|
||||||
analyzer-version = 1
|
analyzer-version = 1
|
||||||
inputs-digest = "7dd24393da8db7d16249fa8f14426fb6418a2cefca2045da212cf4f299a5a1f0"
|
inputs-digest = "328c0e201a8f9b84770fc7b0efb002f50e64da384499776e57cc1edb38b26a51"
|
||||||
solver-name = "gps-cdcl"
|
solver-name = "gps-cdcl"
|
||||||
solver-version = 1
|
solver-version = 1
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/hashicorp/go-syslog"
|
name = "github.com/hashicorp/go-syslog"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
branch = "master"
|
||||||
|
name = "golang.org/x/sys"
|
||||||
|
|
|
@ -22,12 +22,18 @@ type globals struct {
|
||||||
systemLogger *systemLogger
|
systemLogger *systemLogger
|
||||||
fileName *string
|
fileName *string
|
||||||
outFd *os.File
|
outFd *os.File
|
||||||
|
lastMessage string
|
||||||
|
lastOccurrence time.Time
|
||||||
|
occurrences uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_globals = globals{
|
_globals = globals{
|
||||||
logLevel: SeverityLast,
|
logLevel: SeverityLast,
|
||||||
appName: "-",
|
appName: "-",
|
||||||
|
lastMessage: "",
|
||||||
|
lastOccurrence: time.Now(),
|
||||||
|
occurrences: 0,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -42,6 +48,11 @@ const (
|
||||||
SeverityLast
|
SeverityLast
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
FloodDelay = 5 * time.Second
|
||||||
|
FloodMinRepeats = 3
|
||||||
|
)
|
||||||
|
|
||||||
var SeverityName = []string{
|
var SeverityName = []string{
|
||||||
SeverityDebug: "DEBUG",
|
SeverityDebug: "DEBUG",
|
||||||
SeverityInfo: "INFO",
|
SeverityInfo: "INFO",
|
||||||
|
@ -183,6 +194,18 @@ func logf(severity Severity, format string, args ...interface{}) {
|
||||||
}
|
}
|
||||||
_globals.Lock()
|
_globals.Lock()
|
||||||
defer _globals.Unlock()
|
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 {
|
if *_globals.useSyslog && _globals.systemLogger == nil {
|
||||||
systemLogger, err := newSystemLogger(_globals.appName, _globals.syslogFacility)
|
systemLogger, err := newSystemLogger(_globals.appName, _globals.syslogFacility)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
Loading…
Reference in New Issue