diff options
author | Bjørn Erik Pedersen <[email protected]> | 2022-01-06 10:22:19 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2022-01-06 12:27:04 +0100 |
commit | c8b5ab75b743914f89b51046eee8e3daa2eb1eec (patch) | |
tree | f37e135fd0ed109f091676b9885c71e5ddf4e2cb /helpers | |
parent | 85c5b895939031334e2b9caa598cdee45e14dd5b (diff) | |
download | hugo-c8b5ab75b743914f89b51046eee8e3daa2eb1eec.tar.gz hugo-c8b5ab75b743914f89b51046eee8e3daa2eb1eec.zip |
Add --panicOnWarning flag
Fixes #9357
Fixes #9359
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/general.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/helpers/general.go b/helpers/general.go index 74053123f..73b7aff66 100644 --- a/helpers/general.go +++ b/helpers/general.go @@ -331,12 +331,14 @@ func (l *DistinctLogger) Warnf(format string, v ...interface{}) { l.Logger.Warnf(format, v...) }) } + func (l *DistinctLogger) Warnln(v ...interface{}) { logStatement := fmt.Sprint(v...) l.printIfNotPrinted("warnln", logStatement, func() { l.Logger.Warnln(v...) }) } + func (l *DistinctLogger) Errorf(format string, v ...interface{}) { logStatement := fmt.Sprint(v...) l.printIfNotPrinted("errorf", logStatement, func() { @@ -396,7 +398,6 @@ var ( func InitLoggers() { DistinctErrorLog.Reset() DistinctWarnLog.Reset() - } // Deprecated informs about a deprecation, but only once for a given set of arguments' values. @@ -408,7 +409,11 @@ func Deprecated(item, alternative string, err bool) { if err { DistinctErrorLog.Errorf("%s is deprecated and will be removed in Hugo %s. %s", item, hugo.CurrentVersion.Next().ReleaseVersion(), alternative) } else { - DistinctWarnLog.Warnf("%s is deprecated and will be removed in a future release. %s", item, alternative) + var warnPanicMessage string + if !loggers.PanicOnWarning { + warnPanicMessage = "\n\nRe-run Hugo with the flag --panicOnWarning to get a better error message." + } + DistinctWarnLog.Warnf("%s is deprecated and will be removed in a future release. %s%s", item, alternative, warnPanicMessage) } } |