mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-04 00:55:59 +08:00
zap
This commit is contained in:
@@ -56,7 +56,6 @@ type ZapLogger struct {
|
||||
func NewZapLogger() (*ZapLogger, error) {
|
||||
zapConfig := zap.Config{
|
||||
Level: zap.NewAtomicLevelAt(zapcore.DebugLevel),
|
||||
Development: true,
|
||||
Encoding: "json",
|
||||
EncoderConfig: zap.NewProductionEncoderConfig(),
|
||||
DisableStacktrace: true,
|
||||
@@ -78,10 +77,6 @@ func NewZapLogger() (*ZapLogger, error) {
|
||||
return zl, nil
|
||||
}
|
||||
|
||||
func (l *ZapLogger) timeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
|
||||
enc.AppendString(t.Format("2006-01-02 15:04:05"))
|
||||
}
|
||||
|
||||
func (l *ZapLogger) cores() (zap.Option, error) {
|
||||
c := zap.NewProductionEncoderConfig()
|
||||
c.EncodeTime = zapcore.ISO8601TimeEncoder
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"OpenIM/pkg/common/log"
|
||||
"OpenIM/pkg/common/mw/specialerror"
|
||||
"OpenIM/pkg/errs"
|
||||
"OpenIM/pkg/proto/wrapperspb"
|
||||
"context"
|
||||
"fmt"
|
||||
"google.golang.org/grpc"
|
||||
@@ -65,12 +66,12 @@ func rpcServerInterceptor(ctx context.Context, req interface{}, info *grpc.Unary
|
||||
code = errs.ServerInternalError
|
||||
}
|
||||
grpcStatus := status.New(codes.Code(code), codeErr.Msg())
|
||||
//if unwrap != err {
|
||||
// stack := fmt.Sprintf("%+v", err)
|
||||
// if details, err := grpcStatus.WithDetails(wrapperspb.String(stack)); err == nil {
|
||||
// grpcStatus = details
|
||||
// }
|
||||
//}
|
||||
if unwrap != err {
|
||||
stack := fmt.Sprintf("%+v", err)
|
||||
if details, err := grpcStatus.WithDetails(wrapperspb.String(stack)); err == nil {
|
||||
grpcStatus = details
|
||||
}
|
||||
}
|
||||
log.ZWarn(ctx, "rpc resp", unwrap, "funcName", funcName)
|
||||
return nil, grpcStatus.Err()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user