mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Add logging of asciidoc/-tor errors
Add logging of the errors which asciidoc and asciidoctor output to their stderr stream when converting asciidoc documents. Note that asciidoctor's exit code may be SUCCESS even if there are ERROR messages in its stderr output (tested with Asciidoctor 0.1.4 and 1.5.5). Therefore log the stderr output whenever it is non-empty. See #2399
This commit is contained in:
parent
998034faad
commit
9f9b93af2c
1 changed files with 12 additions and 2 deletions
|
@ -546,9 +546,19 @@ func getAsciidocContent(content []byte) []byte {
|
||||||
jww.INFO.Println("Rendering with", path, "...")
|
jww.INFO.Println("Rendering with", path, "...")
|
||||||
cmd := exec.Command(path, "--no-header-footer", "--safe", "-")
|
cmd := exec.Command(path, "--no-header-footer", "--safe", "-")
|
||||||
cmd.Stdin = bytes.NewReader(cleanContent)
|
cmd.Stdin = bytes.NewReader(cleanContent)
|
||||||
var out bytes.Buffer
|
var out, cmderr bytes.Buffer
|
||||||
cmd.Stdout = &out
|
cmd.Stdout = &out
|
||||||
if err := cmd.Run(); err != nil {
|
cmd.Stderr = &cmderr
|
||||||
|
err := cmd.Run()
|
||||||
|
// asciidoctor has exit code 0 even if there are errors in stderr
|
||||||
|
// -> log stderr output regardless of state of err
|
||||||
|
for _, item := range strings.Split(string(cmderr.Bytes()), "\n") {
|
||||||
|
item := strings.TrimSpace(item)
|
||||||
|
if item != "" {
|
||||||
|
jww.ERROR.Println(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
jww.ERROR.Println(err)
|
jww.ERROR.Println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue