mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-18 14:47:03 +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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user