25 lines
441 B
Go
25 lines
441 B
Go
package interceptor
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
type LoggerInterceptor struct{}
|
|
|
|
func NewLoggerInterceptor() *LoggerInterceptor {
|
|
return &LoggerInterceptor{}
|
|
}
|
|
|
|
func (li *LoggerInterceptor) UnaryServerInterceptor(
|
|
ctx context.Context,
|
|
req interface{},
|
|
info *grpc.UnaryServerInfo,
|
|
handler grpc.UnaryHandler,
|
|
) (interface{}, error) {
|
|
log.Printf("gRPC call: %s", info.FullMethod)
|
|
return handler(ctx, req)
|
|
}
|