|
4 | 4 | "bytes" |
5 | 5 | "context" |
6 | 6 | "fmt" |
| 7 | + "io" |
7 | 8 | "net/url" |
8 | 9 | "os" |
9 | 10 | "path/filepath" |
@@ -72,6 +73,8 @@ type system struct { |
72 | 73 | wg sync.WaitGroup |
73 | 74 | teardownOnce sync.Once |
74 | 75 | cancel context.CancelFunc |
| 76 | + |
| 77 | + logWriter *io.PipeWriter |
75 | 78 | } |
76 | 79 |
|
77 | 80 | // Run launches the cluster-api system. |
@@ -272,6 +275,9 @@ func (c *system) Run(ctx context.Context, installConfig *installconfig.InstallCo |
272 | 275 | return fmt.Errorf("unsupported platform %q", platform) |
273 | 276 | } |
274 | 277 |
|
| 278 | + // We only show controller logs if the log level is DEBUG or above |
| 279 | + c.logWriter = logrus.StandardLogger().WriterLevel(logrus.DebugLevel) |
| 280 | + |
275 | 281 | // Run the controllers. |
276 | 282 | for _, ct := range controllers { |
277 | 283 | if err := c.runController(ctx, ct); err != nil { |
@@ -341,6 +347,8 @@ func (c *system) Teardown() { |
341 | 347 | case <-time.After(60 * time.Second): |
342 | 348 | logrus.Warn("Timed out waiting for local Cluster API system to shut down") |
343 | 349 | } |
| 350 | + |
| 351 | + c.logWriter.Close() |
344 | 352 | }) |
345 | 353 | } |
346 | 354 |
|
@@ -505,7 +513,7 @@ func (c *system) runController(ctx context.Context, ct *controller) error { |
505 | 513 |
|
506 | 514 | // Run the controller and store its state. |
507 | 515 | logrus.Infof("Running process: %s with args %v", ct.Name, ct.Args) |
508 | | - if err := pr.Start(ctx, os.Stdout, os.Stderr); err != nil { |
| 516 | + if err := pr.Start(ctx, c.logWriter, c.logWriter); err != nil { |
509 | 517 | return fmt.Errorf("failed to start controller %q: %w", ct.Name, err) |
510 | 518 | } |
511 | 519 | ct.state = pr |
|
0 commit comments