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

Add lazyDebugf method to process the arguments lazily #7158

Closed
wants to merge 1 commit into from

Conversation

aranjans
Copy link
Collaborator

@aranjans aranjans commented Apr 22, 2024

Fixes #7154

RELEASE NOTES:

  • Add LazyDebugf function.

@aranjans aranjans self-assigned this Apr 22, 2024
@aranjans aranjans added the P2 label Apr 22, 2024
@aranjans aranjans added this to the 1.64 Release milestone Apr 22, 2024
@aranjans aranjans requested a review from dfawley April 23, 2024 08:57
@aranjans aranjans marked this pull request as ready for review April 23, 2024 09:13
@dfawley dfawley assigned dfawley and unassigned aranjans Apr 23, 2024
@@ -79,6 +79,34 @@ func (pl *PrefixLogger) Debugf(format string, args ...any) {

}

// LazyDebugf does info logging at verbose level 2, only
// evaluating arguments if logging is enabled.
func (pl *PrefixLogger) LazyDebugf(format string, args ...func() any) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this worth it?

This makes the call site:

logger.LazyDebugf("blah %s %s %v", func() { blah1() }, func() { blah2() }, func() { blah3() })

vs.

if logger.V(2) {
	logger.Infof("blah %s %s %v", blah1(), blah2(), blah3())
}

Yes it's "3 lines instead of 1 line" but:

  1. it's not obvious that Debugf is checking V(2), and
  2. the usage with Lazy is really hard to read and very long because of all the extraneous closures.

I think I'd rather just delete Debugf instead.

Copy link
Collaborator

Choose a reason for hiding this comment

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

How many occurrences of Debugf do we have?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

17 i believe

@dfawley dfawley assigned aranjans and unassigned dfawley Apr 23, 2024
@aranjans
Copy link
Collaborator Author

Taking pause on this sometime to prioritize other issues. Will update this PR based on this comment

@arvindbr8
Copy link
Member

Let's close this PR for now and re-open when we are actively working on it

@arvindbr8 arvindbr8 closed this May 2, 2024
@dfawley dfawley reopened this May 2, 2024
@dfawley dfawley closed this May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delete grpclog's Debugf function
4 participants