Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid showing repeated messages #16118

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 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,17 @@ func (e *hostEngine) Log(_ context.Context, req *pulumirpc.LogRequest) (*pbempty
}
}

if e.previousMessage == message {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're intentionally using the shortened message here, since we don't want to keep a large amount of data in memory.

e.logRepeat++
return &pbempty.Empty{}, nil
}

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
14 changes: 14 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,17 @@ func (e *hostEngine) Log(_ context.Context, req *pulumirpc.LogRequest) (*pbempty
}
}

if e.previousMessage == message {
e.logRepeat++
return &pbempty.Empty{}, nil
}

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