mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Add double checking in Deprecated
To prevent possible duplicate log statements.
This commit is contained in:
parent
6e30c10d09
commit
f8a840a14c
1 changed files with 6 additions and 3 deletions
|
@ -115,15 +115,18 @@ var deprecatedLogs = struct {
|
||||||
}{m: make(map[string]bool)}
|
}{m: make(map[string]bool)}
|
||||||
|
|
||||||
func Deprecated(object, item, alternative string) {
|
func Deprecated(object, item, alternative string) {
|
||||||
|
key := object + item + alternative
|
||||||
deprecatedLogs.RLock()
|
deprecatedLogs.RLock()
|
||||||
logged := deprecatedLogs.m[object+item+alternative]
|
logged := deprecatedLogs.m[key]
|
||||||
deprecatedLogs.RUnlock()
|
deprecatedLogs.RUnlock()
|
||||||
if logged {
|
if logged {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
deprecatedLogs.Lock()
|
deprecatedLogs.Lock()
|
||||||
|
if !deprecatedLogs.m[key] {
|
||||||
jww.ERROR.Printf("%s's %s is deprecated and will be removed in Hugo 0.15. Use %s instead.", object, item, alternative)
|
jww.ERROR.Printf("%s's %s is deprecated and will be removed in Hugo 0.15. Use %s instead.", object, item, alternative)
|
||||||
deprecatedLogs.m[object+item+alternative] = true
|
deprecatedLogs.m[key] = true
|
||||||
|
}
|
||||||
deprecatedLogs.Unlock()
|
deprecatedLogs.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue