diff options
author | tjpcc <tjp@ctrl-c.club> | 2023-09-09 08:42:21 -0600 |
---|---|---|
committer | tjpcc <tjp@ctrl-c.club> | 2023-09-09 08:42:21 -0600 |
commit | 33648cc286e812a8603743c29e96830de3b4acb8 (patch) | |
tree | 2253b0c71035f866fb14e6692baf5587b1925fb4 /contrib/cgi/spartan.go | |
parent | 195bdb565e9cb46e8d88ee364dcfc96a65a7159a (diff) |
log stderr on failed CGIs
Diffstat (limited to 'contrib/cgi/spartan.go')
-rw-r--r-- | contrib/cgi/spartan.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/contrib/cgi/spartan.go b/contrib/cgi/spartan.go index 6994466..272bd92 100644 --- a/contrib/cgi/spartan.go +++ b/contrib/cgi/spartan.go @@ -1,11 +1,13 @@ package cgi import ( + "bytes" "context" "fmt" "strings" sr "tildegit.org/tjp/sliderule" + "tildegit.org/tjp/sliderule/logging" "tildegit.org/tjp/sliderule/spartan" ) @@ -29,11 +31,17 @@ func SpartanCGIDirectory(pathRoot, fsRoot string) sr.Handler { return nil } - stdout, exitCode, err := RunCGI(ctx, request, filepath, pathinfo) + stderr := &bytes.Buffer{} + stdout, exitCode, err := RunCGI(ctx, request, filepath, pathinfo, stderr) if err != nil { return spartan.ServerError(err) } if exitCode != 0 { + ctx.Value("warnlog").(logging.Logger).Log( + "msg", "cgi exited with non-zero exit code", + "code", exitCode, + "stderr", stderr.String(), + ) return spartan.ServerError(fmt.Errorf("CGI process exited with status %d", exitCode)) } |