Hide logs behind document.Debug flag

This commit is contained in:
Niklas Fasching 2018-12-19 00:26:57 +01:00
parent 42dc70e7ad
commit c554023a60

View file

@ -19,6 +19,7 @@ type Document struct {
BufferSettings map[string]string BufferSettings map[string]string
DefaultSettings map[string]string DefaultSettings map[string]string
Error error Error error
Debug bool
} }
type Writer interface { type Writer interface {
@ -189,7 +190,9 @@ func (d *Document) parseOne(i int, stop stopFn) (consumed int, node Node) {
if consumed != 0 { if consumed != 0 {
return consumed, node return consumed, node
} }
log.Printf("Could not parse token %#v: Falling back to treating it as plain text.", d.tokens[i]) if d.Debug {
log.Printf("Could not parse token %#v: Falling back to treating it as plain text.", d.tokens[i])
}
m := plainTextRegexp.FindStringSubmatch(d.tokens[i].matches[0]) m := plainTextRegexp.FindStringSubmatch(d.tokens[i].matches[0])
d.tokens[i] = token{"text", len(m[1]), m[2], m} d.tokens[i] = token{"text", len(m[1]), m[2], m}
return d.parseOne(i, stop) return d.parseOne(i, stop)