@@ -7,14 +7,18 @@ import (
77 "io"
88 "os"
99 "os/exec"
10+ "regexp"
1011
1112 "github.com/bitrise-io/go-utils/v2/command"
1213 "github.com/bitrise-io/go-utils/v2/log"
1314 "github.com/bitrise-io/go-xcode/v2/errorfinder"
15+ "github.com/bitrise-io/go-xcode/v2/loginterceptor"
1416 version "github.com/hashicorp/go-version"
1517)
1618
17- const xcbeautify = "xcbeautify"
19+ const (
20+ xcbeautify = "xcbeautify"
21+ )
1822
1923// XcbeautifyRunner is a xcodebuild runner that uses xcbeautify as log formatter
2024type XcbeautifyRunner struct {
@@ -36,13 +40,21 @@ func (c *XcbeautifyRunner) Run(workDir string, xcodebuildArgs []string, xcbeauti
3640 buildOutBuffer bytes.Buffer
3741 pipeReader , pipeWriter = io .Pipe ()
3842 buildOutWriter = io .MultiWriter (& buildOutBuffer , pipeWriter )
43+ prefixRegexp = regexp .MustCompile (prefix )
44+ interceptor = loginterceptor .NewPrefixInterceptor (prefixRegexp , os .Stdout , buildOutWriter , c .logger )
3945 )
4046
47+ defer func () {
48+ if err := interceptor .Close (); err != nil {
49+ c .logger .Warnf ("Failed to close log interceptor, error: %s" , err )
50+ }
51+ }()
52+
4153 // For parallel and concurrent destination testing, it helps to use unbuffered I/O for stdout and to redirect stderr to stdout.
4254 // NSUnbufferedIO=YES xcodebuild [args] 2>&1 | xcbeautify
4355 buildCmd := c .commandFactory .Create ("xcodebuild" , xcodebuildArgs , & command.Opts {
44- Stdout : buildOutWriter ,
45- Stderr : buildOutWriter ,
56+ Stdout : interceptor ,
57+ Stderr : interceptor ,
4658 Env : unbufferedIOEnv ,
4759 Dir : workDir ,
4860 ErrorFinder : errorfinder .FindXcodebuildErrors ,
0 commit comments