Fix some recently broken embedded templates

And add tests for them.

Fixes #4757
This commit is contained in:
Bjørn Erik Pedersen
2018-05-23 10:03:11 +02:00
parent 4ddcf52ccc
commit 35ccf06dae
11 changed files with 111 additions and 21 deletions

View File

@@ -260,7 +260,8 @@ func (p *PathSpec) ThemeSet() bool {
return p.theme != ""
}
type logPrinter interface {
// LogPrinter is the common interface of the JWWs loggers.
type LogPrinter interface {
// Println is the only common method that works in all of JWWs loggers.
Println(a ...interface{})
}
@@ -268,7 +269,7 @@ type logPrinter interface {
// DistinctLogger ignores duplicate log statements.
type DistinctLogger struct {
sync.RWMutex
logger logPrinter
logger LogPrinter
m map[string]bool
}
@@ -309,6 +310,11 @@ func NewDistinctErrorLogger() *DistinctLogger {
return &DistinctLogger{m: make(map[string]bool), logger: jww.ERROR}
}
// NewDistinctLogger creates a new DistinctLogger that logs to the provided logger.
func NewDistinctLogger(logger LogPrinter) *DistinctLogger {
return &DistinctLogger{m: make(map[string]bool), logger: logger}
}
// NewDistinctWarnLogger creates a new DistinctLogger that logs WARNs
func NewDistinctWarnLogger() *DistinctLogger {
return &DistinctLogger{m: make(map[string]bool), logger: jww.WARN}