Skip to content

Commit 99692e9

Browse files
committed
avoid showing repeated messages
Sometimes we show hundreds of repeated messages in the logs, e.g. "waiting for quiescence; 3 outputs outstanding". This just makes the logs harder to read. Since we need to wait for the test to finish before any of this is shown anyway, only log each message once and show a little blurb about how often the message has been repeated. (Note that for simplicity if the last message is repeated we don't show the same blurb, but that should be okay since the last messages we're logging are always different.)
1 parent 4dbdf54 commit 99692e9

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

sdk/nodejs/cmd/pulumi-language-nodejs/language_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ import (
4141
type hostEngine struct {
4242
pulumirpc.UnimplementedEngineServer
4343
t *testing.T
44+
45+
logRepeat int
46+
previousMessage string
4447
}
4548

4649
func (e *hostEngine) Log(_ context.Context, req *pulumirpc.LogRequest) (*pbempty.Empty, error) {
@@ -66,6 +69,15 @@ func (e *hostEngine) Log(_ context.Context, req *pulumirpc.LogRequest) (*pbempty
6669
}
6770
}
6871

72+
if e.previousMessage == message {
73+
e.logRepeat++
74+
return &pbempty.Empty{}, nil
75+
} else if e.logRepeat > 1 {
76+
e.t.Logf("Last message repeated %d times", e.logRepeat)
77+
e.logRepeat = 1
78+
e.previousMessage = message
79+
}
80+
6981
if req.StreamId != 0 {
7082
e.t.Logf("(%d) %s[%s]: %s", req.StreamId, sev, req.Urn, message)
7183
} else {

sdk/python/cmd/pulumi-language-python/language_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ import (
4343
type hostEngine struct {
4444
pulumirpc.UnimplementedEngineServer
4545
t *testing.T
46+
47+
logRepeat int
48+
previousMessage string
4649
}
4750

4851
func (e *hostEngine) Log(_ context.Context, req *pulumirpc.LogRequest) (*pbempty.Empty, error) {
@@ -68,6 +71,15 @@ func (e *hostEngine) Log(_ context.Context, req *pulumirpc.LogRequest) (*pbempty
6871
}
6972
}
7073

74+
if e.previousMessage == message {
75+
e.logRepeat++
76+
return &pbempty.Empty{}, nil
77+
} else if e.logRepeat > 1 {
78+
e.t.Logf("Last message repeated %d times", e.logRepeat)
79+
e.logRepeat = 1
80+
e.previousMessage = message
81+
}
82+
7183
if req.StreamId != 0 {
7284
e.t.Logf("(%d) %s[%s]: %s", req.StreamId, sev, req.Urn, message)
7385
} else {

0 commit comments

Comments
 (0)