mirror of
https://github.com/netbirdio/netbird.git
synced 2026-07-20 23:41:28 +02:00
client: configure gRPC logger to use standard logger output based on log path
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"strconv"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"gopkg.in/natefinch/lumberjack.v2"
|
||||
|
||||
"github.com/netbirdio/netbird/formatter"
|
||||
@@ -48,6 +49,14 @@ func InitLog(logLevel string, logPath string) error {
|
||||
formatter.SetTextFormatter(log.StandardLogger())
|
||||
}
|
||||
log.SetLevel(level)
|
||||
|
||||
if logPath == "console" {
|
||||
grpclog.SetLoggerV2(grpclog.NewLoggerV2(io.Discard, io.Discard, io.Discard))
|
||||
} else {
|
||||
logOut := log.StandardLogger().Out
|
||||
grpclog.SetLoggerV2(grpclog.NewLoggerV2(logOut, logOut, logOut))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user