Skip to content

Commit

Permalink
avoid showing repeated messages
Browse files Browse the repository at this point in the history
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.)
  • Loading branch information
tgummerer committed May 3, 2024
1 parent b82d4af commit 31c7b5c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sdk/nodejs/cmd/pulumi-language-nodejs/language_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ import (
type hostEngine struct {
pulumirpc.UnimplementedEngineServer
t *testing.T

logRepeat int
previousMessage string
}

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

if e.previousMessage == message {
e.logRepeat++
return &pbempty.Empty{}, nil
} else if e.logRepeat > 1 {
e.t.Logf("Last message repeated %d times", e.logRepeat)
e.logRepeat = 1
e.previousMessage = message
}

if req.StreamId != 0 {
e.t.Logf("(%d) %s[%s]: %s", req.StreamId, sev, req.Urn, message)
} else {
Expand Down
12 changes: 12 additions & 0 deletions sdk/python/cmd/pulumi-language-python/language_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ import (
type hostEngine struct {
pulumirpc.UnimplementedEngineServer
t *testing.T

logRepeat int
previousMessage string
}

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

if e.previousMessage == message {
e.logRepeat++
return &pbempty.Empty{}, nil
} else if e.logRepeat > 1 {
e.t.Logf("Last message repeated %d times", e.logRepeat)
e.logRepeat = 1
e.previousMessage = message
}

if req.StreamId != 0 {
e.t.Logf("(%d) %s[%s]: %s", req.StreamId, sev, req.Urn, message)
} else {
Expand Down

0 comments on commit 31c7b5c

Please sign in to comment.