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)}
|
||||
|
||||
func Deprecated(object, item, alternative string) {
|
||||
key := object + item + alternative
|
||||
deprecatedLogs.RLock()
|
||||
logged := deprecatedLogs.m[object+item+alternative]
|
||||
logged := deprecatedLogs.m[key]
|
||||
deprecatedLogs.RUnlock()
|
||||
if logged {
|
||||
return
|
||||
}
|
||||
deprecatedLogs.Lock()
|
||||
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
|
||||
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)
|
||||
deprecatedLogs.m[key] = true
|
||||
}
|
||||
deprecatedLogs.Unlock()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue