ref: baa975082c6809c8a02a8109ec3062a2b7d48344
parent: 3e8b5a5c0157fdcf93588a42fbc90b3cd898f6b1
author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
date: Wed Oct 23 18:04:52 EDT 2019
deps: Update to Chroma v0.6.8 to fix a crash Also improve relevant logging. Fixes #6450
--- a/common/loggers/loggers.go
+++ b/common/loggers/loggers.go
@@ -15,11 +15,13 @@
import (
"bytes"
+ "fmt"
"io"
"io/ioutil"
"log"
"os"
"regexp"
+ "runtime"
"github.com/gohugoio/hugo/common/terminal"
@@ -142,6 +144,26 @@
}
+type fatalLogWriter int
+
+func (s fatalLogWriter) Write(p []byte) (n int, err error) {
+ trace := make([]byte, 1500)
+ runtime.Stack(trace, true)
+ fmt.Printf("\n===========\n\n%s\n", trace)
+ os.Exit(-1)
+
+ return 0, nil
+}
+
+var fatalLogListener = func(t jww.Threshold) io.Writer {
+ if t != jww.LevelError {
+ // Only interested in ERROR
+ return nil
+ }
+
+ return new(fatalLogWriter)
+}
+
func newLogger(stdoutThreshold, logThreshold jww.Threshold, outHandle, logHandle io.Writer, saveErrors bool) *Logger {
errorCounter := &jww.Counter{}
warnCounter := &jww.Counter{}
@@ -156,7 +178,6 @@
// Only interested in ERROR
return nil
}
-
return errorBuff
}
--- a/go.mod
+++ b/go.mod
@@ -5,7 +5,7 @@
github.com/BurntSushi/toml v0.3.1
github.com/PuerkitoBio/purell v1.1.0
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
- github.com/alecthomas/chroma v0.6.7
+ github.com/alecthomas/chroma v0.6.8
github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1 // indirect
github.com/armon/go-radix v1.0.0
github.com/aws/aws-sdk-go v1.19.40
--- a/go.sum
+++ b/go.sum
@@ -42,6 +42,8 @@
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
github.com/alecthomas/chroma v0.6.7 h1:1hKci+AyKOxJrugR9veaocu9DQGR2/GecI72BpaO0Rg=
github.com/alecthomas/chroma v0.6.7/go.mod h1:zVlgtbRS7BJDrDY9SB238RmpoCBCYFlLmcfZ3durxTk=
+github.com/alecthomas/chroma v0.6.8 h1:TW4JJaIdbAbMyUtGEd6BukFlOKYvVQz3vVhLBEUNwMU=
+github.com/alecthomas/chroma v0.6.8/go.mod h1:o9ohftueRi7H5be3+Q2cQCNa/YnLBFUNx40ZJfGVFKA=
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo=
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
github.com/alecthomas/kong v0.1.17-0.20190424132513-439c674f7ae0/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=
--- a/helpers/pygments.go
+++ b/helpers/pygments.go
@@ -82,7 +82,7 @@
err = chromaHighlight(b, code, lang, style, f)
if err != nil {
- jww.ERROR.Print(err.Error())
+ jww.ERROR.Printf("Highlight failed: %s\nLang: %q\nCode: \n%s", err, lang, code)
return code, err
}