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(*): support ignore logs by WithDecider #648

Closed
wants to merge 1 commit into from

Conversation

linhbkhn95
Copy link

@linhbkhn95 linhbkhn95 commented Sep 22, 2023

Background

I just upgraded from v1 to v2. But I have a problem with the logging package.
Currently, I have not seen an ignore logging feature like v1 at v2.

Changes

  • Add WithDecider option into interceptor.
    Example:
const TestPingFullMethodName = "/testing.testpb.v1.TestService/Ping"
fullMethodNamesWithoutLogging := []string{TestPingFullMethodName}

opts := []grpc.ServerOption{
 grpc.UnaryInterceptor(logging.UnaryServerInterceptor(s.logger, logging.WithDecider(ignoreLoggingDecider(fullMethodNamesWithoutLogging)))),
 }

func ignoreLoggingDecider(fullMethodNames []string) logging.Decider {
   return func(fullMethodName string) bool {
   	for _, f := range fullMethodNames {
   		if fullMethodName == f {
   			return false
   		}
   	}
   	return true
   }
}

Verification

  • Unitest and integration test
  • Integration with my internal services

@google-cla
Copy link

google-cla bot commented Sep 22, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@linhbkhn95 linhbkhn95 marked this pull request as draft September 22, 2023 03:01
@linhbkhn95 linhbkhn95 marked this pull request as ready for review September 22, 2023 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant