mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
deps: Update to Chroma v0.6.8 to fix a crash
Also improve relevant logging. Fixes #6450
This commit is contained in:
parent
3e8b5a5c01
commit
baa975082c
4 changed files with 26 additions and 3 deletions
|
@ -15,11 +15,13 @@ package loggers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"github.com/gohugoio/hugo/common/terminal"
|
"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 {
|
func newLogger(stdoutThreshold, logThreshold jww.Threshold, outHandle, logHandle io.Writer, saveErrors bool) *Logger {
|
||||||
errorCounter := &jww.Counter{}
|
errorCounter := &jww.Counter{}
|
||||||
warnCounter := &jww.Counter{}
|
warnCounter := &jww.Counter{}
|
||||||
|
@ -156,7 +178,6 @@ func newLogger(stdoutThreshold, logThreshold jww.Threshold, outHandle, logHandle
|
||||||
// Only interested in ERROR
|
// Only interested in ERROR
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return errorBuff
|
return errorBuff
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -5,7 +5,7 @@ require (
|
||||||
github.com/BurntSushi/toml v0.3.1
|
github.com/BurntSushi/toml v0.3.1
|
||||||
github.com/PuerkitoBio/purell v1.1.0
|
github.com/PuerkitoBio/purell v1.1.0
|
||||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
|
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/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1 // indirect
|
||||||
github.com/armon/go-radix v1.0.0
|
github.com/armon/go-radix v1.0.0
|
||||||
github.com/aws/aws-sdk-go v1.19.40
|
github.com/aws/aws-sdk-go v1.19.40
|
||||||
|
|
2
go.sum
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/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 h1:1hKci+AyKOxJrugR9veaocu9DQGR2/GecI72BpaO0Rg=
|
||||||
github.com/alecthomas/chroma v0.6.7/go.mod h1:zVlgtbRS7BJDrDY9SB238RmpoCBCYFlLmcfZ3durxTk=
|
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 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo=
|
||||||
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
|
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=
|
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)
|
err = chromaHighlight(b, code, lang, style, f)
|
||||||
if err != nil {
|
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
|
return code, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue