"github.com/bep/logg"
)
-func InitGlobalLogger(panicOnWarnings bool) {
+func InitGlobalLogger(level logg.Level, panicOnWarnings bool) {
logMu.Lock()
defer logMu.Unlock()
var logHookLast func(e *logg.Entry) error
log = New(
Options{
+ Level: level,
Distinct: true,
HandlerPost: logHookLast,
},
var log Logger
func init() {
- InitGlobalLogger(false)
+ InitGlobalLogger(logg.LevelWarn, false)
}
// This is unfortunate, but these are global settings.
tpl.SetSecurityAllowActionJSTmpl(configs.Base.Security.GoTemplates.AllowActionJSTmpl)
- loggers.InitGlobalLogger(configs.Base.PanicOnWarning)
- return configs, nil
+ loggers.InitGlobalLogger(d.Logger.Level(), configs.Base.PanicOnWarning)
+ return configs, nil
}
// ConfigSourceDescriptor describes where to find the config (e.g. config.toml etc.).
default:
return v
}
-
}
func (l *configLoader) loadConfigMain(d ConfigSourceDescriptor) (config.LoadConfigResult, modules.ModulesConfig, error) {
"github.com/gohugoio/hugo/hugofs"
+ "github.com/gohugoio/hugo/common/loggers"
"github.com/gohugoio/hugo/common/para"
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/resources/postpub"
return err
}
- errorCount := h.Log.LoggCount(logg.LevelError)
+ errorCount := h.Log.LoggCount(logg.LevelError) + loggers.Log().LoggCount(logg.LevelError)
if errorCount > 0 {
return fmt.Errorf("logged %d error(s)", errorCount)
}
--- /dev/null
+
+
+hugo -e info --logLevel info
+stdout 'INFO item was deprecated in Hugo'
+
+hugo -e warn --logLevel warn
+stdout 'WARN item was deprecated in Hugo'
+
+! hugo -e error --logLevel warn
+stdout 'ERROR item was deprecated in Hugo'
+
+-- hugo.toml --
+baseURL = "https://example.com/"
+disableKinds = ["taxonomy", "term"]
+-- layouts/index.html --
+Deprecate:
+{{ if eq hugo.Environment "info" }}
+ {{ debug.TestDeprecationInfo "item" "alternative" }}
+{{ end }}
+{{ if eq hugo.Environment "warn" }}
+ {{ debug.TestDeprecationWarn "item" "alternative" }}
+{{ end }}
+{{ if eq hugo.Environment "error" }}
+ {{ debug.TestDeprecationErr "item" "alternative" }}
+{{ end }}
\ No newline at end of file
"github.com/spf13/cast"
"github.com/yuin/goldmark/util"
+ "github.com/gohugoio/hugo/common/hugo"
"github.com/gohugoio/hugo/deps"
)
// This is used in templates, we need to return something.
return ""
}
+
+// Internal template func, used in tests only.
+func (ns *Namespace) TestDeprecationInfo(item, alternative string) string {
+ v := hugo.CurrentVersion
+ hugo.Deprecate(item, alternative, v.String())
+ return ""
+}
+
+// Internal template func, used in tests only.
+func (ns *Namespace) TestDeprecationWarn(item, alternative string) string {
+ v := hugo.CurrentVersion
+ v.Minor -= 6
+ hugo.Deprecate(item, alternative, v.String())
+ return ""
+}
+
+// Internal template func, used in tests only.
+func (ns *Namespace) TestDeprecationErr(item, alternative string) string {
+ v := hugo.CurrentVersion
+ v.Minor -= 12
+ hugo.Deprecate(item, alternative, v.String())
+ return ""
+}