Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbep <bjorn.erik.pedersen@gmail.com>2015-03-12 18:10:14 +0300
committerbep <bjorn.erik.pedersen@gmail.com>2015-03-12 18:10:34 +0300
commit6e30c10d09ec60e8df3b4c17e6ab7a5896245928 (patch)
tree11ed7d79ccb57677e04b7ec395ca3e25b90ba2ac /helpers
parentf848dc92dbf65321ee3eff7ebbb9253e1cb3a512 (diff)
Add deprecated logger
Diffstat (limited to 'helpers')
-rw-r--r--helpers/general.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/helpers/general.go b/helpers/general.go
index 891e5b80f..4219186ad 100644
--- a/helpers/general.go
+++ b/helpers/general.go
@@ -20,12 +20,14 @@ import (
"errors"
"fmt"
bp "github.com/spf13/hugo/bufferpool"
+ jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/viper"
"io"
"net"
"path/filepath"
"reflect"
"strings"
+ "sync"
)
// Filepath separator defined by os.Separator.
@@ -106,6 +108,25 @@ func ThemeSet() bool {
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.
func SliceToLower(s []string) []string {
if s == nil {