summaryrefslogtreecommitdiff
path: root/ui/status
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2019-06-09 19:40:08 -0700
committer Colin Cross <ccross@android.com> 2019-06-12 21:30:56 -0700
commite0df1a36b265ce271a9a723a09ecf892ffefe36f (patch)
tree7c6ec9f984ddc388cf5479b127500cdac7fa0038 /ui/status
parent097ed2a37cca619a9be0e109a108f3d474b576d1 (diff)
Move all output through StatusOutput
Write log output through StatusOutput so that the status implementation can synchronize it with its own output. Test: status_test.go Change-Id: I917bdeeea4759a12b6b4aa6d6d86ee18a2771723
Diffstat (limited to 'ui/status')
-rw-r--r--ui/status/log.go10
-rw-r--r--ui/status/status.go3
-rw-r--r--ui/status/status_test.go5
3 files changed, 18 insertions, 0 deletions
diff --git a/ui/status/log.go b/ui/status/log.go
index 921aa4401..7badac73c 100644
--- a/ui/status/log.go
+++ b/ui/status/log.go
@@ -71,6 +71,11 @@ func (v *verboseLog) Message(level MsgLevel, message string) {
fmt.Fprintf(v.w, "%s%s\n", level.Prefix(), message)
}
+func (v *verboseLog) Write(p []byte) (int, error) {
+ fmt.Fprint(v.w, string(p))
+ return len(p), nil
+}
+
type errorLog struct {
w io.WriteCloser
@@ -134,3 +139,8 @@ func (e *errorLog) Message(level MsgLevel, message string) {
fmt.Fprintf(e.w, "error: %s\n", message)
}
+
+func (e *errorLog) Write(p []byte) (int, error) {
+ fmt.Fprint(e.w, string(p))
+ return len(p), nil
+}
diff --git a/ui/status/status.go b/ui/status/status.go
index 46ec72e80..3d8cd7a2c 100644
--- a/ui/status/status.go
+++ b/ui/status/status.go
@@ -173,6 +173,9 @@ type StatusOutput interface {
// Flush is called when your outputs should be flushed / closed. No
// output is expected after this call.
Flush()
+
+ // Write lets StatusOutput implement io.Writer
+ Write(p []byte) (n int, err error)
}
// Status is the multiplexer / accumulator between ToolStatus instances (via
diff --git a/ui/status/status_test.go b/ui/status/status_test.go
index e62785f43..949458222 100644
--- a/ui/status/status_test.go
+++ b/ui/status/status_test.go
@@ -27,6 +27,11 @@ func (c *counterOutput) FinishAction(result ActionResult, counts Counts) {
func (c counterOutput) Message(level MsgLevel, msg string) {}
func (c counterOutput) Flush() {}
+func (c counterOutput) Write(p []byte) (int, error) {
+ // Discard writes
+ return len(p), nil
+}
+
func (c counterOutput) Expect(t *testing.T, counts Counts) {
if Counts(c) == counts {
return