Skip to content

Commit 10b4737

Browse files
authored
Log stderr on errors (#58)
Fixes #32.
1 parent 0f04bba commit 10b4737

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

provider/pkg/provider/command.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ func (c *command) run(ctx context.Context, command string, host *provider.HostCl
113113

114114
stdoutch := make(chan struct{})
115115
stderrch := make(chan struct{})
116-
go copyOutput(ctx, host, urn, stdouttee, stdoutch)
117-
go copyOutput(ctx, host, urn, stderrtee, stderrch)
116+
go copyOutput(ctx, host, urn, stdouttee, stdoutch, diag.Debug)
117+
go copyOutput(ctx, host, urn, stderrtee, stderrch, diag.Error)
118118

119119
err = cmd.Start()
120120
pid := cmd.Process.Pid
@@ -140,11 +140,11 @@ func (c *command) run(ctx context.Context, command string, host *provider.HostCl
140140
return strings.TrimSuffix(stdoutbuf.String(), "\n"), strings.TrimSuffix(stderrbuf.String(), "\n"), id, nil
141141
}
142142

143-
func copyOutput(ctx context.Context, host *provider.HostClient, urn resource.URN, r io.Reader, doneCh chan<- struct{}) {
143+
func copyOutput(ctx context.Context, host *provider.HostClient, urn resource.URN, r io.Reader, doneCh chan<- struct{}, severity diag.Severity) {
144144
defer close(doneCh)
145145
scanner := bufio.NewScanner(r)
146146
for scanner.Scan() {
147-
err := host.Log(ctx, diag.Debug, urn, scanner.Text())
147+
err := host.Log(ctx, severity, urn, scanner.Text())
148148
if err != nil {
149149
return
150150
}

provider/pkg/provider/remotecommand.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ import (
2424
"strings"
2525
"time"
2626

27-
"github.com/pulumi/pulumi/sdk/v3/go/common/util/retry"
28-
2927
"golang.org/x/crypto/ssh"
3028

3129
"github.com/pulumi/pulumi/pkg/v3/resource/provider"
30+
"github.com/pulumi/pulumi/sdk/v3/go/common/diag"
3231
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
32+
"github.com/pulumi/pulumi/sdk/v3/go/common/util/retry"
3333
)
3434

3535
type remoteconnection struct {
@@ -175,8 +175,8 @@ func (c *remotecommand) run(ctx context.Context, cmd string, host *provider.Host
175175

176176
stdoutch := make(chan struct{})
177177
stderrch := make(chan struct{})
178-
go copyOutput(ctx, host, urn, stdouttee, stdoutch)
179-
go copyOutput(ctx, host, urn, stderrtee, stderrch)
178+
go copyOutput(ctx, host, urn, stdouttee, stdoutch, diag.Debug)
179+
go copyOutput(ctx, host, urn, stderrtee, stderrch, diag.Info)
180180

181181
err = session.Run(cmd)
182182

0 commit comments

Comments
 (0)