mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
log level
This commit is contained in:
parent
f6761d2544
commit
1578176f39
@ -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:
|
||||
|
@ -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"`
|
||||
|
@ -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()},
|
||||
|
Loading…
x
Reference in New Issue
Block a user