mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-19 09:14:13 +00:00
Add deprecated logger
This commit is contained in:
parent
f848dc92db
commit
6e30c10d09
1 changed files with 21 additions and 0 deletions
|
@ -20,12 +20,14 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
bp "github.com/spf13/hugo/bufferpool"
|
bp "github.com/spf13/hugo/bufferpool"
|
||||||
|
jww "github.com/spf13/jwalterweatherman"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Filepath separator defined by os.Separator.
|
// Filepath separator defined by os.Separator.
|
||||||
|
@ -106,6 +108,25 @@ func ThemeSet() bool {
|
||||||
return viper.GetString("theme") != ""
|
return viper.GetString("theme") != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Avoid spamming the logs with errors
|
||||||
|
var deprecatedLogs = struct {
|
||||||
|
sync.RWMutex
|
||||||
|
m map[string]bool
|
||||||
|
}{m: make(map[string]bool)}
|
||||||
|
|
||||||
|
func Deprecated(object, item, alternative string) {
|
||||||
|
deprecatedLogs.RLock()
|
||||||
|
logged := deprecatedLogs.m[object+item+alternative]
|
||||||
|
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
|
||||||
|
deprecatedLogs.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
// SliceToLower goes through the source slice and lowers all values.
|
// SliceToLower goes through the source slice and lowers all values.
|
||||||
func SliceToLower(s []string) []string {
|
func SliceToLower(s []string) []string {
|
||||||
if s == nil {
|
if s == nil {
|
||||||
|
|
Loading…
Reference in a new issue