Improve stderr logging for PostCSS and simlilar

Fixes #7584
This commit is contained in:
Bjørn Erik Pedersen
2020-08-20 18:43:09 +02:00
parent ae63c2b5c9
commit ec37420468
7 changed files with 77 additions and 25 deletions

View File

@@ -14,6 +14,9 @@
package loggers
import (
"bytes"
"fmt"
"log"
"testing"
qt "github.com/frankban/quicktest"
@@ -30,3 +33,17 @@ func TestLogger(t *testing.T) {
c.Assert(l.ErrorCounter.Count(), qt.Equals, uint64(2))
}
func TestLoggerToWriterWithPrefix(t *testing.T) {
c := qt.New(t)
var b bytes.Buffer
logger := log.New(&b, "", 0)
w := LoggerToWriterWithPrefix(logger, "myprefix")
fmt.Fprint(w, "Hello Hugo!")
c.Assert(b.String(), qt.Equals, "myprefix: Hello Hugo!\n")
}