1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

aliases: Log the "alias-exists" hook output, for debugging

The output of the alias-exists hook is unused, so currently it's
discarded silently.

However, it can be very useful to debug issues when the hook is not
working as expected.

So this patch makes chasquid log the combined output (stdout and stderr)
to the execution trace.
This commit is contained in:
Alberto Bertogli
2020-05-22 14:40:58 +01:00
parent bee7a9f193
commit 9fe790d7c6

View File

@@ -453,12 +453,15 @@ func (v *Resolver) runExistsHook(addr string) bool {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel() defer cancel()
cmd := exec.CommandContext(ctx, v.ExistsHook, addr) cmd := exec.CommandContext(ctx, v.ExistsHook, addr)
err := cmd.Run()
out, err := cmd.CombinedOutput()
tr.Debugf("output: %q", string(out))
if err != nil { if err != nil {
tr.Debugf("not exists: %v", err) tr.Debugf("not exists: %v", err)
hookResults.Add("exists:false", 1) hookResults.Add("exists:false", 1)
return false return false
} }
tr.Debugf("exists") tr.Debugf("exists")
hookResults.Add("exists:true", 1) hookResults.Add("exists:true", 1)
return true return true