build_api.py: Support tee-log via environment variable.

See go/build-log-compatibility for short doc.

BUG=chromium:1012460
TEST=manual

Change-Id: Ib79233a723060e023d10448ab2a2c89a5c992a33
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1984881
Reviewed-by: Alex Klein <saklein@chromium.org>
Commit-Queue: Michael Mortensen <mmortensen@google.com>
Tested-by: Michael Mortensen <mmortensen@google.com>
diff --git a/scripts/build_api.py b/scripts/build_api.py
index 35e0752..8c2e139 100644
--- a/scripts/build_api.py
+++ b/scripts/build_api.py
@@ -171,6 +171,10 @@
     if opts.tee_log:
       stack.Add(tee.Tee, opts.tee_log)
       logging.info('Teeing stdout and stderr to %s', opts.tee_log)
+    tee_log_env_value = os.environ.get('BUILD_API_TEE_LOG_FILE')
+    if tee_log_env_value:
+      stack.Add(tee.Tee, tee_log_env_value)
+      logging.info('Teeing stdout and stderr to env path %s', tee_log_env_value)
 
     if opts.mock_invalid:
       # --mock-invalid handling. We print error messages, but no output is ever