mirror of
https://github.com/netbirdio/netbird.git
synced 2026-05-01 22:56:41 +00:00
client: update gRPC logging to ignore stdout and stderr outputs
This commit is contained in:
@@ -23,9 +23,10 @@ func UnaryClientInterceptor() grpc.UnaryClientInterceptor {
|
|||||||
) error {
|
) error {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
isStdout := log.StandardLogger().Out == os.Stdout
|
// don't log if log output is not a file
|
||||||
|
ignoreLog := log.StandardLogger().Out == os.Stdout || log.StandardLogger().Out == os.Stderr
|
||||||
|
|
||||||
if !isStdout {
|
if !ignoreLog {
|
||||||
// log the request
|
// log the request
|
||||||
if msg, ok := req.(proto.Message); ok {
|
if msg, ok := req.(proto.Message); ok {
|
||||||
if jsonReq, err := protojson.Marshal(msg); err == nil {
|
if jsonReq, err := protojson.Marshal(msg); err == nil {
|
||||||
@@ -43,7 +44,7 @@ func UnaryClientInterceptor() grpc.UnaryClientInterceptor {
|
|||||||
duration := time.Since(start)
|
duration := time.Since(start)
|
||||||
|
|
||||||
// log the response
|
// log the response
|
||||||
if !isStdout {
|
if !ignoreLog {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("gRPC request failed: method=%s, duration=%v, error=%v", method, duration, err)
|
log.Errorf("gRPC request failed: method=%s, duration=%v, error=%v", method, duration, err)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user