Add environment variable to force keeping ANSI codes
If SOONG_UI_ANSI_OUTPUT is set to a true value force the simple status output to keep ANSI codes. This will allow buildbots to collect logs with ANSI codes in them. Smart status output is not affected as it always keeps ANSI codes. Bug: 147310922 Test: manual Change-Id: I0b78ceebb65125b8e8dafb4787816fb679d3eb3e
This commit is contained in:
@@ -24,15 +24,17 @@ import (
|
||||
type simpleStatusOutput struct {
|
||||
writer io.Writer
|
||||
formatter formatter
|
||||
keepANSI bool
|
||||
}
|
||||
|
||||
// NewSimpleStatusOutput returns a StatusOutput that represents the
|
||||
// current build status similarly to Ninja's built-in terminal
|
||||
// output.
|
||||
func NewSimpleStatusOutput(w io.Writer, formatter formatter) status.StatusOutput {
|
||||
func NewSimpleStatusOutput(w io.Writer, formatter formatter, keepANSI bool) status.StatusOutput {
|
||||
return &simpleStatusOutput{
|
||||
writer: w,
|
||||
formatter: formatter,
|
||||
keepANSI: keepANSI,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +56,9 @@ func (s *simpleStatusOutput) FinishAction(result status.ActionResult, counts sta
|
||||
progress := s.formatter.progress(counts) + str
|
||||
|
||||
output := s.formatter.result(result)
|
||||
output = string(stripAnsiEscapes([]byte(output)))
|
||||
if !s.keepANSI {
|
||||
output = string(stripAnsiEscapes([]byte(output)))
|
||||
}
|
||||
|
||||
if output != "" {
|
||||
fmt.Fprint(s.writer, progress, "\n", output)
|
||||
|
Reference in New Issue
Block a user