Skip to content

Commit

Permalink
log execute commands
Browse files Browse the repository at this point in the history
  • Loading branch information
et-nik committed Feb 15, 2024
1 parent 32da251 commit 19c9c7d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/app/server/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (c *Commands) Handle(ctx context.Context, readWriter io.ReadWriter) error {

func (c Commands) executeCommand(ctx context.Context, msg commandExec, writer io.Writer) error {
logger.WithField(ctx, "command", msg.Command).Debug("Executing command")

out, exitCode, err := components.Exec(ctx, msg.Command, contracts.ExecutorOptions{
WorkDir: msg.WorkDir,
})
Expand All @@ -50,6 +51,12 @@ func (c Commands) executeCommand(ctx context.Context, msg commandExec, writer io
})
}

logger.Logger(ctx).
WithField("command", msg.Command).
WithField("exitCode", exitCode).
WithField("outSize", len(out)).
Debug("Command executed")

return response.WriteResponse(writer, Response{
Code: response.StatusOK,
ExitCode: exitCode,
Expand Down

0 comments on commit 19c9c7d

Please sign in to comment.