Skip to content
Permalink
Browse files

deps: Update to Chroma v0.6.8 to fix a crash

Also improve relevant logging.

Fixes #6450
  • Loading branch information...
bep committed Oct 23, 2019
1 parent 3e8b5a5 commit baa975082c6809c8a02a8109ec3062a2b7d48344
Showing with 26 additions and 3 deletions.
  1. +22 −1 common/loggers/loggers.go
  2. +1 −1 go.mod
  3. +2 −0 go.sum
  4. +1 −1 helpers/pygments.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
}

2 go.mod
@@ -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
2 go.sum
@@ -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=
@@ -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
}

0 comments on commit baa9750

Please sign in to comment.
You can’t perform that action at this time.