return &DistinctLogger{m: make(map[string]bool), logger: jww.ERROR}
}
+// NewDistinctWarnLogger creates a new DistinctLogger that logs WARNs
+func NewDistinctWarnLogger() *DistinctLogger {
+ return &DistinctLogger{m: make(map[string]bool), logger: jww.WARN}
+}
+
// NewDistinctFeedbackLogger creates a new DistinctLogger that can be used
// to give feedback to the user while not spamming with duplicates.
func NewDistinctFeedbackLogger() *DistinctLogger {
// DistinctErrorLog can be used to avoid spamming the logs with errors.
DistinctErrorLog = NewDistinctErrorLogger()
+ // DistinctWarnLog can be used to avoid spamming the logs with warnings.
+ DistinctWarnLog = NewDistinctWarnLogger()
+
// DistinctFeedbackLog can be used to avoid spamming the logs with info messages.
DistinctFeedbackLog = NewDistinctFeedbackLogger()
)
// InitLoggers sets up the global distinct loggers.
func InitLoggers() {
- DistinctErrorLog = NewDistinctErrorLogger()
+ jww.ResetLogCounters()
}
// Deprecated informs about a deprecation, but only once for a given set of arguments' values.
func (p *PageOutput) Render(layout ...string) template.HTML {
if !p.checkRender() {
- return template.HTML("")
+ return ""
}
l, err := p.layouts(layout...)
func (p *Page) Render(layout ...string) template.HTML {
if !p.checkRender() {
- return template.HTML("")
+ return ""
}
p.pageOutputInit.Do(func() {
// for list pages.
func (p *Page) checkRender() bool {
if p.Kind != KindPage {
- helpers.DistinctErrorLog.Printf(".Render only available for regular pages, not for of kind %q. You probably meant .Site.RegularPages and not.Site.Pages.", p.Kind)
+ helpers.DistinctWarnLog.Printf(".Render only available for regular pages, not for of kind %q. You probably meant .Site.RegularPages and not.Site.Pages.", p.Kind)
return false
}
return true