From 3bdc5a6d14b8fa33c1af64e20530bb39b5fd7748 Mon Sep 17 00:00:00 2001 From: Patrick Robinson Date: Tue, 17 Dec 2024 12:33:55 +1100 Subject: [PATCH] Enable process debug logging We currently don't pass the agentLogger object into Shell, so I can't easily use the existing logger. So we create one in using plain text mode --- internal/shell/shell.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/shell/shell.go b/internal/shell/shell.go index d32d18da00..81e9597f61 100644 --- a/internal/shell/shell.go +++ b/internal/shell/shell.go @@ -565,6 +565,9 @@ func (s *Shell) executeCommand(ctx context.Context, cmdCfg process.Config, stdou cmdCfg.Stderr = io.Discard } + var processLogger logger.Logger + processLogger = logger.Discard + if s.debug { // Display normally-hidden output streams using log streamer. if cmdCfg.Stdout == io.Discard { @@ -578,6 +581,9 @@ func (s *Shell) executeCommand(ctx context.Context, cmdCfg process.Config, stdou defer stdErrStreamer.Close() cmdCfg.Stderr = stdErrStreamer } + + // This should respect the log format we set for the agent + processLogger = logger.NewConsoleLogger(logger.NewTextPrinter(cmdCfg.Stderr), os.Exit) } if s.commandLog != nil { @@ -590,7 +596,7 @@ func (s *Shell) executeCommand(ctx context.Context, cmdCfg process.Config, stdou return nil } - p := process.New(logger.Discard, cmdCfg) + p := process.New(processLogger, cmdCfg) s.proc.Store(p) if err := p.Run(ctx); err != nil {