summaryrefslogtreecommitdiffstats
path: root/helpers/general.go
diff options
context:
space:
mode:
authorbep <bjorn.erik.pedersen@gmail.com>2015-04-03 22:29:57 +0200
committerbep <bjorn.erik.pedersen@gmail.com>2015-04-03 22:30:08 +0200
commitbeb66c19a46189c729807d0b95186996588f40fc (patch)
tree373671ccd4ad71121d30e341efb9344d4c6e2a75 /helpers/general.go
parentbe57ec5331896dc6162bacdd3a1a679a62432ac9 (diff)
helpers: add some missing documentation
Diffstat (limited to 'helpers/general.go')
-rw-r--r--helpers/general.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/helpers/general.go b/helpers/general.go
index 48e7dbd01..f6e0cbc4f 100644
--- a/helpers/general.go
+++ b/helpers/general.go
@@ -159,6 +159,8 @@ type DistinctErrorLogger struct {
m map[string]bool
}
+// Printf will ERROR log the string returned from fmt.Sprintf given the arguments,
+// but not if it has been logged before.
func (l *DistinctErrorLogger) Printf(format string, v ...interface{}) {
logStatement := fmt.Sprintf(format, v...)
l.RLock()
@@ -176,6 +178,7 @@ func (l *DistinctErrorLogger) Printf(format string, v ...interface{}) {
l.Unlock()
}
+// NewDistinctErrorLogger creates a new DistinctErrorLogger
func NewDistinctErrorLogger() *DistinctErrorLogger {
return &DistinctErrorLogger{m: make(map[string]bool)}
}
@@ -183,6 +186,7 @@ func NewDistinctErrorLogger() *DistinctErrorLogger {
// Avoid spamming the logs with errors
var deprecatedLogger = NewDistinctErrorLogger()
+// Deprecated logs ERROR logs about a deprecation, but only once for a given set of arguments' values.
func Deprecated(object, item, alternative string) {
deprecatedLogger.Printf("%s's %s is deprecated and will be removed in Hugo %s. Use %s instead.", object, item, NextHugoReleaseVersion(), alternative)
}
@@ -227,7 +231,7 @@ func Seq(args ...interface{}) ([]int, error) {
return nil, errors.New("Invalid argument(s) to Seq")
}
- var inc int = 1
+ var inc = 1
var last int
var first = intArgs[0]