diff options
| author | Colin Cross <ccross@android.com> | 2019-06-09 19:40:08 -0700 |
|---|---|---|
| committer | Michael Bestas <mkbestas@lineageos.org> | 2019-12-11 19:03:31 +0200 |
| commit | 6ed655d7628ace7662b5a25d2a4b20d82b72bb64 (patch) | |
| tree | eb4a4085212b2864ce38bfbe4d6c9eebbaae36fa /ui | |
| parent | 43b1ba24465e544ff1529521910097c7b1e7de82 (diff) | |
| download | build_soong-6ed655d7628ace7662b5a25d2a4b20d82b72bb64.tar.gz build_soong-6ed655d7628ace7662b5a25d2a4b20d82b72bb64.tar.bz2 build_soong-6ed655d7628ace7662b5a25d2a4b20d82b72bb64.zip | |
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')
| -rw-r--r-- | ui/status/log.go | 10 | ||||
| -rw-r--r-- | ui/status/status.go | 3 | ||||
| -rw-r--r-- | ui/status/status_test.go | 5 | ||||
| -rw-r--r-- | ui/terminal/dumb_status.go | 5 | ||||
| -rw-r--r-- | ui/terminal/smart_status.go | 7 | ||||
| -rw-r--r-- | ui/tracer/status.go | 5 |
6 files changed, 35 insertions, 0 deletions
diff --git a/ui/status/log.go b/ui/status/log.go index 921aa440..7badac73 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 46ec72e8..3d8cd7a2 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 e62785f4..94945822 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 diff --git a/ui/terminal/dumb_status.go b/ui/terminal/dumb_status.go index 08ef3733..201770fa 100644 --- a/ui/terminal/dumb_status.go +++ b/ui/terminal/dumb_status.go @@ -64,3 +64,8 @@ func (s *dumbStatusOutput) FinishAction(result status.ActionResult, counts statu } func (s *dumbStatusOutput) Flush() {} + +func (s *dumbStatusOutput) Write(p []byte) (int, error) { + fmt.Fprint(s.writer, string(p)) + return len(p), nil +} diff --git a/ui/terminal/smart_status.go b/ui/terminal/smart_status.go index a52fdc2b..9a4931c0 100644 --- a/ui/terminal/smart_status.go +++ b/ui/terminal/smart_status.go @@ -104,6 +104,13 @@ func (s *smartStatusOutput) Flush() { s.requestLine() } +func (s *smartStatusOutput) Write(p []byte) (int, error) { + s.lock.Lock() + defer s.lock.Unlock() + s.print(string(p)) + return len(p), nil +} + func (s *smartStatusOutput) requestLine() { if !s.haveBlankLine { fmt.Fprintln(s.writer) diff --git a/ui/tracer/status.go b/ui/tracer/status.go index af50e2d4..c8312551 100644 --- a/ui/tracer/status.go +++ b/ui/tracer/status.go @@ -85,3 +85,8 @@ func (s *statusOutput) FinishAction(result status.ActionResult, counts status.Co func (s *statusOutput) Flush() {} func (s *statusOutput) Message(level status.MsgLevel, message string) {} + +func (s *statusOutput) Write(p []byte) (int, error) { + // Discard writes + return len(p), nil +} |
