mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-27 20:30:40 +08:00
log level
This commit is contained in:
parent
f6761d2544
commit
1578176f39
@ -19,7 +19,7 @@ mysql:
|
|||||||
dbMaxOpenConns: 100
|
dbMaxOpenConns: 100
|
||||||
dbMaxIdleConns: 10
|
dbMaxIdleConns: 10
|
||||||
dbMaxLifeTime: 5
|
dbMaxLifeTime: 5
|
||||||
logLevel: 4 #1=slient 2=error 3=warn 4=info
|
logLevel: 6 #1=slient 2=error 3=warn 4=info
|
||||||
slowThreshold: 500
|
slowThreshold: 500
|
||||||
|
|
||||||
mongo:
|
mongo:
|
||||||
|
@ -13,11 +13,6 @@ type UserModel struct {
|
|||||||
UserID string `gorm:"column:user_id;primary_key;size:64"`
|
UserID string `gorm:"column:user_id;primary_key;size:64"`
|
||||||
Nickname string `gorm:"column:name;size:255"`
|
Nickname string `gorm:"column:name;size:255"`
|
||||||
FaceURL string `gorm:"column:face_url;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"`
|
|
||||||
Ex string `gorm:"column:ex;size:1024"`
|
Ex string `gorm:"column:ex;size:1024"`
|
||||||
CreateTime time.Time `gorm:"column:create_time;index:create_time; autoCreateTime"`
|
CreateTime time.Time `gorm:"column:create_time;index:create_time; autoCreateTime"`
|
||||||
AppMangerLevel int32 `gorm:"column:app_manger_level;default:18"`
|
AppMangerLevel int32 `gorm:"column:app_manger_level;default:18"`
|
||||||
|
@ -2,13 +2,14 @@ package log
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
"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/constant"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
|
||||||
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
@ -17,6 +18,15 @@ import (
|
|||||||
var (
|
var (
|
||||||
pkgLogger Logger = &ZapLogger{}
|
pkgLogger Logger = &ZapLogger{}
|
||||||
sp = string(filepath.Separator)
|
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
|
// InitFromConfig initializes a Zap-based logger
|
||||||
@ -51,7 +61,7 @@ type ZapLogger struct {
|
|||||||
|
|
||||||
func NewZapLogger() (*ZapLogger, error) {
|
func NewZapLogger() (*ZapLogger, error) {
|
||||||
zapConfig := zap.Config{
|
zapConfig := zap.Config{
|
||||||
Level: zap.NewAtomicLevelAt(zapcore.Level(config.Config.Log.RemainLogLevel)),
|
Level: zap.NewAtomicLevelAt(logLevelMap[config.Config.Log.RemainLogLevel]),
|
||||||
Encoding: "json",
|
Encoding: "json",
|
||||||
EncoderConfig: zap.NewProductionEncoderConfig(),
|
EncoderConfig: zap.NewProductionEncoderConfig(),
|
||||||
InitialFields: map[string]interface{}{"PID": os.Getegid()},
|
InitialFields: map[string]interface{}{"PID": os.Getegid()},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user