mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
Revise the deprecation logging
This introduces a more automatic way of increasing the log levels for deprecation log statements based on the version it was deprecated. The thresholds are a little arbitrary, but * We log INFO for 6 releases * We log WARN for another 6 releases * THen ERROR (failing the build) This should give theme authors plenty of time to catch up without having the log filled with warnings.
This commit is contained in:
@@ -25,7 +25,6 @@ import (
|
||||
|
||||
"github.com/bep/logg"
|
||||
"github.com/gohugoio/hugo/hugofs/files"
|
||||
"github.com/gohugoio/hugo/langs"
|
||||
"github.com/gohugoio/hugo/publisher"
|
||||
"github.com/gohugoio/hugo/tpl"
|
||||
|
||||
@@ -40,14 +39,8 @@ import (
|
||||
"github.com/gohugoio/hugo/output"
|
||||
|
||||
"github.com/fsnotify/fsnotify"
|
||||
"github.com/gohugoio/hugo/helpers"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// To avoid circular dependencies, we set this here.
|
||||
langs.DeprecationFunc = helpers.Deprecated
|
||||
}
|
||||
|
||||
// Build builds all sites. If filesystem events are provided,
|
||||
// this is considered to be a potential partial rebuild.
|
||||
func (h *HugoSites) Build(config BuildCfg, events ...fsnotify.Event) error {
|
||||
|
@@ -130,7 +130,7 @@ func (p *pageMeta) Aliases() []string {
|
||||
}
|
||||
|
||||
func (p *pageMeta) Author() page.Author {
|
||||
helpers.Deprecated(".Author", "Use taxonomies.", false)
|
||||
hugo.Deprecate(".Author", "Use taxonomies.", "v0.98.0")
|
||||
authors := p.Authors()
|
||||
|
||||
for _, author := range authors {
|
||||
@@ -140,7 +140,7 @@ func (p *pageMeta) Author() page.Author {
|
||||
}
|
||||
|
||||
func (p *pageMeta) Authors() page.AuthorList {
|
||||
helpers.Deprecated(".Authors", "Use taxonomies.", true)
|
||||
hugo.Deprecate(".Author", "Use taxonomies.", "v0.112.0")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ func (p *pageMeta) Path() string {
|
||||
{{ $path = .Path }}
|
||||
{{ end }}
|
||||
`
|
||||
helpers.Deprecated(".Path when the page is backed by a file", "We plan to use Path for a canonical source path and you probably want to check the source is a file. To get the current behaviour, you can use a construct similar to the one below:\n"+example, false)
|
||||
p.s.Log.Warnln(".Path when the page is backed by a file is deprecated. We plan to use Path for a canonical source path and you probably want to check the source is a file. To get the current behaviour, you can use a construct similar to the one below:\n" + example)
|
||||
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,6 @@ import (
|
||||
"github.com/gohugoio/hugo/config"
|
||||
"github.com/gohugoio/hugo/config/allconfig"
|
||||
"github.com/gohugoio/hugo/deps"
|
||||
"github.com/gohugoio/hugo/helpers"
|
||||
"github.com/gohugoio/hugo/identity"
|
||||
"github.com/gohugoio/hugo/langs"
|
||||
"github.com/gohugoio/hugo/langs/i18n"
|
||||
@@ -48,9 +47,7 @@ import (
|
||||
"github.com/gohugoio/hugo/tpl/tplimpl"
|
||||
)
|
||||
|
||||
var (
|
||||
_ page.Site = (*Site)(nil)
|
||||
)
|
||||
var _ page.Site = (*Site)(nil)
|
||||
|
||||
type Site struct {
|
||||
conf *allconfig.Config
|
||||
@@ -236,7 +233,6 @@ func NewHugoSites(cfg deps.DepsCfg) (*HugoSites, error) {
|
||||
}
|
||||
|
||||
return h, err
|
||||
|
||||
}
|
||||
|
||||
func newHugoSitesNew(cfg deps.DepsCfg, d *deps.Deps, sites []*Site) (*HugoSites, error) {
|
||||
@@ -358,7 +354,7 @@ func newHugoSitesNew(cfg deps.DepsCfg, d *deps.Deps, sites []*Site) (*HugoSites,
|
||||
// Returns true if we're running in a server.
|
||||
// Deprecated: use hugo.IsServer instead
|
||||
func (s *Site) IsServer() bool {
|
||||
helpers.Deprecated(".Site.IsServer", "Use hugo.IsServer instead.", false)
|
||||
hugo.Deprecate(".Site.IsServer", "Use hugo.IsServer instead.", "v0.120.0")
|
||||
return s.conf.Internal.Running
|
||||
}
|
||||
|
||||
@@ -377,7 +373,7 @@ func (s *Site) Copyright() string {
|
||||
}
|
||||
|
||||
func (s *Site) RSSLink() template.URL {
|
||||
helpers.Deprecated("Site.RSSLink", "Use the Output Format's Permalink method instead, e.g. .OutputFormats.Get \"RSS\".Permalink", false)
|
||||
hugo.Deprecate("Site.RSSLink", "Use the Output Format's Permalink method instead, e.g. .OutputFormats.Get \"RSS\".Permalink", "v0.114.0")
|
||||
rssOutputFormat := s.home.OutputFormats().Get("rss")
|
||||
return template.URL(rssOutputFormat.Permalink())
|
||||
}
|
||||
@@ -449,13 +445,13 @@ func (s *Site) Social() map[string]string {
|
||||
|
||||
// Deprecated: Use .Site.Config.Services.Disqus.Shortname instead
|
||||
func (s *Site) DisqusShortname() string {
|
||||
helpers.Deprecated(".Site.DisqusShortname", "Use .Site.Config.Services.Disqus.Shortname instead.", false)
|
||||
hugo.Deprecate(".Site.DisqusShortname", "Use .Site.Config.Services.Disqus.Shortname instead.", "v0.120.0")
|
||||
return s.Config().Services.Disqus.Shortname
|
||||
}
|
||||
|
||||
// Deprecated: Use .Site.Config.Services.GoogleAnalytics.ID instead
|
||||
func (s *Site) GoogleAnalytics() string {
|
||||
helpers.Deprecated(".Site.GoogleAnalytics", "Use .Site.Config.Services.GoogleAnalytics.ID instead.", false)
|
||||
hugo.Deprecate(".Site.GoogleAnalytics", "Use .Site.Config.Services.GoogleAnalytics.ID instead.", "v0.120.0")
|
||||
return s.Config().Services.GoogleAnalytics.ID
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user