cmd/buildlet: use plan9LogWriter only on GCE

plan9LogWriter was added to truncate log writes
to 128 bytes to work around an issue with
GCE serial port.

This change enables plan9LogWriter only on GCE,
so the log writes aren't truncated when running
in other environments.

Change-Id: I4c5dcb27e5daa8e68f2a1e1abfce96d709d50a0f
Reviewed-on: https://go-review.googlesource.com/c/build/+/225697
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: David du Colombier <0intro@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
diff --git a/cmd/buildlet/buildlet.go b/cmd/buildlet/buildlet.go
index 7a7a563..9ccb554 100644
--- a/cmd/buildlet/buildlet.go
+++ b/cmd/buildlet/buildlet.go
@@ -132,7 +132,9 @@
 	onGCE := metadata.OnGCE()
 	switch runtime.GOOS {
 	case "plan9":
-		log.SetOutput(&plan9LogWriter{w: os.Stderr})
+		if onGCE {
+			log.SetOutput(&gcePlan9LogWriter{w: os.Stderr})
+		}
 	case "linux":
 		if onGCE && !inKube {
 			if w, err := os.OpenFile("/dev/console", os.O_WRONLY, 0); err == nil {
@@ -1642,14 +1644,14 @@
 	h.h.ServeHTTP(w, r)
 }
 
-// plan9LogWriter truncates log writes to 128 bytes,
-// to work around some Plan 9 and/or GCE serial port bug.
-type plan9LogWriter struct {
+// gcePlan9LogWriter truncates log writes to 128 bytes,
+// to work around a GCE serial port bug affecting Plan 9.
+type gcePlan9LogWriter struct {
 	w   io.Writer
 	buf []byte
 }
 
-func (pw *plan9LogWriter) Write(p []byte) (n int, err error) {
+func (pw *gcePlan9LogWriter) Write(p []byte) (n int, err error) {
 	const max = 128 - len("\n\x00")
 	if len(p) < max {
 		return pw.w.Write(p)