diff options
author | C. Hoeppler <hoeppler@gmx.net> | 2016-10-13 07:34:47 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-10-13 13:48:30 +0200 |
commit | 9f9b93af2c379b10d2d5c514cfe5f0658795b9bb (patch) | |
tree | 6f58838466bf2b88e74778261c00a12be8ff4242 /helpers/content.go | |
parent | 998034faad2b994e9e9f785208a0f2c14dc06854 (diff) |
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
Diffstat (limited to 'helpers/content.go')
-rw-r--r-- | helpers/content.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/helpers/content.go b/helpers/content.go index afefb604d..f2909f208 100644 --- a/helpers/content.go +++ b/helpers/content.go @@ -546,9 +546,19 @@ func getAsciidocContent(content []byte) []byte { jww.INFO.Println("Rendering with", path, "...") cmd := exec.Command(path, "--no-header-footer", "--safe", "-") cmd.Stdin = bytes.NewReader(cleanContent) - var out bytes.Buffer + var out, cmderr bytes.Buffer 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) } |