From 9fe790d7c6d0b9b98c1f63651d2d8ff4eac74d0e Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Fri, 22 May 2020 14:40:58 +0100 Subject: [PATCH] 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. --- internal/aliases/aliases.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/aliases/aliases.go b/internal/aliases/aliases.go index df2e1f7..fc29951 100644 --- a/internal/aliases/aliases.go +++ b/internal/aliases/aliases.go @@ -453,12 +453,15 @@ func (v *Resolver) runExistsHook(addr string) bool { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() cmd := exec.CommandContext(ctx, v.ExistsHook, addr) - err := cmd.Run() + + out, err := cmd.CombinedOutput() + tr.Debugf("output: %q", string(out)) if err != nil { tr.Debugf("not exists: %v", err) hookResults.Add("exists:false", 1) return false } + tr.Debugf("exists") hookResults.Add("exists:true", 1) return true