diff --git a/config/config.yaml b/config/config.yaml index 4b909a143..15e2fea15 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -19,7 +19,7 @@ mysql: dbMaxOpenConns: 100 dbMaxIdleConns: 10 dbMaxLifeTime: 5 - logLevel: 4 #1=slient 2=error 3=warn 4=info + logLevel: 6 #1=slient 2=error 3=warn 4=info slowThreshold: 500 mongo: diff --git a/pkg/common/db/table/relation/user.go b/pkg/common/db/table/relation/user.go index 7121b4e5f..b9b62ee0f 100644 --- a/pkg/common/db/table/relation/user.go +++ b/pkg/common/db/table/relation/user.go @@ -10,14 +10,9 @@ const ( ) type UserModel struct { - UserID string `gorm:"column:user_id;primary_key;size:64"` - Nickname string `gorm:"column:name;size:255"` - FaceURL string `gorm:"column:face_url;size:255"` - //Gender int32 `gorm:"column:gender"` - //AreaCode string `gorm:"column:area_code;size:8" json:"areaCode"` - //PhoneNumber string `gorm:"column:phone_number;size:32"` - //Birth time.Time `gorm:"column:birth"` - //Email string `gorm:"column:email;size:64"` + UserID string `gorm:"column:user_id;primary_key;size:64"` + Nickname string `gorm:"column:name;size:255"` + FaceURL string `gorm:"column:face_url;size:255"` Ex string `gorm:"column:ex;size:1024"` CreateTime time.Time `gorm:"column:create_time;index:create_time; autoCreateTime"` AppMangerLevel int32 `gorm:"column:app_manger_level;default:18"` diff --git a/pkg/common/log/zap.go b/pkg/common/log/zap.go index 0954161c9..948d871f5 100644 --- a/pkg/common/log/zap.go +++ b/pkg/common/log/zap.go @@ -2,21 +2,31 @@ package log import ( "context" + "os" + "path/filepath" + "time" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/config" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext" rotatelogs "github.com/lestrrat-go/file-rotatelogs" - "os" - "path/filepath" - "time" "go.uber.org/zap" "go.uber.org/zap/zapcore" ) var ( - pkgLogger Logger = &ZapLogger{} - sp = string(filepath.Separator) + pkgLogger Logger = &ZapLogger{} + sp = string(filepath.Separator) + logLevelMap = map[int]zapcore.Level{ + 6: zapcore.DebugLevel, + 5: zapcore.DebugLevel, + 4: zapcore.InfoLevel, + 3: zapcore.WarnLevel, + 2: zapcore.ErrorLevel, + 1: zapcore.FatalLevel, + 0: zapcore.PanicLevel, + } ) // InitFromConfig initializes a Zap-based logger @@ -51,7 +61,7 @@ type ZapLogger struct { func NewZapLogger() (*ZapLogger, error) { zapConfig := zap.Config{ - Level: zap.NewAtomicLevelAt(zapcore.Level(config.Config.Log.RemainLogLevel)), + Level: zap.NewAtomicLevelAt(logLevelMap[config.Config.Log.RemainLogLevel]), Encoding: "json", EncoderConfig: zap.NewProductionEncoderConfig(), InitialFields: map[string]interface{}{"PID": os.Getegid()},