|
4 | 4 | "bytes" |
5 | 5 | "context" |
6 | 6 | "fmt" |
| 7 | + "io" |
7 | 8 | "net/url" |
8 | 9 | "os" |
9 | 10 | "path/filepath" |
@@ -71,6 +72,8 @@ type system struct { |
71 | 72 | wg sync.WaitGroup |
72 | 73 | teardownOnce sync.Once |
73 | 74 | cancel context.CancelFunc |
| 75 | + |
| 76 | + logWriter *io.PipeWriter |
74 | 77 | } |
75 | 78 |
|
76 | 79 | // Run launches the cluster-api system. |
@@ -259,6 +262,9 @@ func (c *system) Run(ctx context.Context, installConfig *installconfig.InstallCo |
259 | 262 | return fmt.Errorf("unsupported platform %q", platform) |
260 | 263 | } |
261 | 264 |
|
| 265 | + // We only show controller logs if the log level is DEBUG or above |
| 266 | + c.logWriter = logrus.StandardLogger().WriterLevel(logrus.DebugLevel) |
| 267 | + |
262 | 268 | // Run the controllers. |
263 | 269 | for _, ct := range controllers { |
264 | 270 | if err := c.runController(ctx, ct); err != nil { |
@@ -328,6 +334,8 @@ func (c *system) Teardown() { |
328 | 334 | case <-time.After(60 * time.Second): |
329 | 335 | logrus.Warn("Timed out waiting for local Cluster API system to shut down") |
330 | 336 | } |
| 337 | + |
| 338 | + c.logWriter.Close() |
331 | 339 | }) |
332 | 340 | } |
333 | 341 |
|
@@ -492,7 +500,7 @@ func (c *system) runController(ctx context.Context, ct *controller) error { |
492 | 500 |
|
493 | 501 | // Run the controller and store its state. |
494 | 502 | logrus.Infof("Running process: %s with args %v", ct.Name, ct.Args) |
495 | | - if err := pr.Start(ctx, os.Stdout, os.Stderr); err != nil { |
| 503 | + if err := pr.Start(ctx, c.logWriter, c.logWriter); err != nil { |
496 | 504 | return fmt.Errorf("failed to start controller %q: %w", ct.Name, err) |
497 | 505 | } |
498 | 506 | ct.state = pr |
|
0 commit comments