Apply kati output rewriting to dumpvars

This way we strip out ANSI codes when using dumb terminals. It's likely
overkill to use katiRewriteOutput, but we should rarely see any output
on stderr while dumping variables. This also lets us turn on kati_stats.

Bug: 71729611
Test: lunch missing-eng             (colored error)
Test: lunch missing-eng 2>&1 | cat  (non-colored)
Test: TERM=dumb lunch missing-eng   (non-colored)
Change-Id: Ic63fd42d82a4a64e5c68aecd9ae0f242a0d703f1
diff --git a/ui/build/context.go b/ui/build/context.go
index 52a337d..0636631 100644
--- a/ui/build/context.go
+++ b/ui/build/context.go
@@ -103,6 +103,13 @@
 	return false
 }
 
+func (c ContextImpl) IsErrTerminal() bool {
+	if term, ok := os.LookupEnv("TERM"); ok {
+		return term != "dumb" && isTerminal(c.Stderr())
+	}
+	return false
+}
+
 func (c ContextImpl) TermWidth() (int, bool) {
 	return termWidth(c.Stdout())
 }