diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-10-23 22:04:52 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-10-24 11:11:18 +0200 |
commit | baa975082c6809c8a02a8109ec3062a2b7d48344 (patch) | |
tree | 61820ab09d58b1fb18099b3910dc5f6179991368 | |
parent | 3e8b5a5c0157fdcf93588a42fbc90b3cd898f6b1 (diff) |
deps: Update to Chroma v0.6.8 to fix a crash
Also improve relevant logging.
Fixes #6450
-rw-r--r-- | common/loggers/loggers.go | 23 | ||||
-rw-r--r-- | go.mod | 2 | ||||
-rw-r--r-- | go.sum | 2 | ||||
-rw-r--r-- | helpers/pygments.go | 2 |
4 files changed, 26 insertions, 3 deletions
diff --git a/common/loggers/loggers.go b/common/loggers/loggers.go index 082fd1487..8766e6aaf 100644 --- a/common/loggers/loggers.go +++ b/common/loggers/loggers.go @@ -15,11 +15,13 @@ package loggers import ( "bytes" + "fmt" "io" "io/ioutil" "log" "os" "regexp" + "runtime" "github.com/gohugoio/hugo/common/terminal" @@ -142,6 +144,26 @@ func getLogWriters(outHandle, logHandle io.Writer) (io.Writer, io.Writer) { } +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 @@ func newLogger(stdoutThreshold, logThreshold jww.Threshold, outHandle, logHandle // Only interested in ERROR return nil } - return errorBuff } @@ -5,7 +5,7 @@ require ( 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 @@ -42,6 +42,8 @@ github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm 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= diff --git a/helpers/pygments.go b/helpers/pygments.go index 0fe1e7592..4d7631ced 100644 --- a/helpers/pygments.go +++ b/helpers/pygments.go @@ -82,7 +82,7 @@ func (h highlighters) chromaHighlight(code, lang, optsStr string) (string, error 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 } |