mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Merge remote-tracking branch 'origin/errcode' into errcode
This commit is contained in:
commit
53d13ee17c
@ -24,7 +24,6 @@ mysql:
|
||||
|
||||
mongo:
|
||||
dbUri: ""#当dbUri值不为空则直接使用该值
|
||||
#dbAddress: 127.0.0.1:37017 #单机时为mongo地址,使用分片集群时,为mongos地址 默认即可
|
||||
dbAddress: [ 127.0.0.1:37017 ] #单机时为mongo地址,使用分片集群时,为mongos地址 默认即可
|
||||
dbDirect: false
|
||||
dbTimeout: 60
|
||||
@ -161,6 +160,8 @@ log:
|
||||
remainRotationCount: 2 #日志数量
|
||||
#日志级别 6表示全都打印,测试阶段建议设置为6
|
||||
remainLogLevel: 6
|
||||
stderr: false
|
||||
|
||||
elasticSearchSwitch: false
|
||||
elasticSearchAddr: [ 127.0.0.1:9201 ]
|
||||
elasticSearchUser: ""
|
||||
|
@ -182,6 +182,7 @@ type config struct {
|
||||
RotationTime int `yaml:"rotationTime"`
|
||||
RemainRotationCount uint `yaml:"remainRotationCount"`
|
||||
RemainLogLevel uint `yaml:"remainLogLevel"`
|
||||
Stderr bool `yaml:"stderr"`
|
||||
ElasticSearchSwitch bool `yaml:"elasticSearchSwitch"`
|
||||
ElasticSearchAddr []string `yaml:"elasticSearchAddr"`
|
||||
ElasticSearchUser string `yaml:"elasticSearchUser"`
|
||||
|
@ -1 +1,88 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"OpenIM/pkg/common/tracelog"
|
||||
"context"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func ShowLog(ctx context.Context) {
|
||||
t := ctx.Value(tracelog.TraceLogKey).(*tracelog.FuncInfos)
|
||||
OperationID := tracelog.GetOperationID(ctx)
|
||||
for _, v := range *t.Funcs {
|
||||
if v.Err != nil {
|
||||
ctxLogger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": ctxLogger.Pid,
|
||||
"FilePath": v.File,
|
||||
}).Errorln("func: ", v.FuncName, " args: ", v.Args, v.Err.Error())
|
||||
} else {
|
||||
switch v.LogLevel {
|
||||
case logrus.InfoLevel:
|
||||
ctxLogger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": ctxLogger.Pid,
|
||||
"FilePath": v.File,
|
||||
}).Infoln("func: ", v.FuncName, " args: ", v.Args)
|
||||
case logrus.DebugLevel:
|
||||
ctxLogger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": ctxLogger.Pid,
|
||||
"FilePath": v.File,
|
||||
}).Debugln("func: ", v.FuncName, " args: ", v.Args)
|
||||
case logrus.WarnLevel:
|
||||
ctxLogger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": ctxLogger.Pid,
|
||||
"FilePath": v.File,
|
||||
}).Warnln("func: ", v.FuncName, " args: ", v.Args)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func InfoWithCtx(ctx context.Context, args ...interface{}) {
|
||||
t := ctx.Value(tracelog.TraceLogKey).(*tracelog.FuncInfos)
|
||||
OperationID := tracelog.GetOperationID(ctx)
|
||||
for _, v := range *t.Funcs {
|
||||
logger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": logger.Pid,
|
||||
}).Infoln(v.Args, args)
|
||||
}
|
||||
}
|
||||
|
||||
func DebugWithCtx(ctx context.Context, args ...interface{}) {
|
||||
t := ctx.Value(tracelog.TraceLogKey).(*tracelog.FuncInfos)
|
||||
OperationID := tracelog.GetOperationID(ctx)
|
||||
for _, v := range *t.Funcs {
|
||||
logger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": logger.Pid,
|
||||
}).Debugln(v.Args, args)
|
||||
}
|
||||
}
|
||||
|
||||
func ErrorWithCtx(ctx context.Context, args ...interface{}) {
|
||||
t := ctx.Value(tracelog.TraceLogKey).(*tracelog.FuncInfos)
|
||||
OperationID := tracelog.GetOperationID(ctx)
|
||||
for _, v := range *t.Funcs {
|
||||
if v.Err != nil {
|
||||
logger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": logger.Pid,
|
||||
}).Errorln(v.Err, v.Args, args)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func WarnWithCtx(ctx context.Context, args ...interface{}) {
|
||||
t := ctx.Value(tracelog.TraceLogKey).(*tracelog.FuncInfos)
|
||||
OperationID := tracelog.GetOperationID(ctx)
|
||||
for _, v := range *t.Funcs {
|
||||
logger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": logger.Pid,
|
||||
}).Warnln(v.Args, args)
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,7 @@ package log
|
||||
|
||||
import (
|
||||
"OpenIM/pkg/common/config"
|
||||
"OpenIM/pkg/common/tracelog"
|
||||
"bufio"
|
||||
"context"
|
||||
//"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
@ -16,8 +14,8 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var logger Logger = *LogrusLogger
|
||||
var ctxLogger Logger = *LogrusLogger
|
||||
var logger *LogrusLogger
|
||||
var ctxLogger *LogrusLogger
|
||||
|
||||
type LogrusLogger struct {
|
||||
*logrus.Logger
|
||||
@ -193,84 +191,3 @@ func NewWarn(OperationID string, args ...interface{}) {
|
||||
"PID": logger.Pid,
|
||||
}).Warnln(args)
|
||||
}
|
||||
|
||||
func ShowLog(ctx context.Context) {
|
||||
t := ctx.Value(tracelog.TraceLogKey).(*tracelog.FuncInfos)
|
||||
OperationID := tracelog.GetOperationID(ctx)
|
||||
for _, v := range *t.Funcs {
|
||||
if v.Err != nil {
|
||||
ctxLogger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": ctxLogger.Pid,
|
||||
"FilePath": v.File,
|
||||
}).Errorln("func: ", v.FuncName, " args: ", v.Args, v.Err.Error())
|
||||
} else {
|
||||
switch v.LogLevel {
|
||||
case logrus.InfoLevel:
|
||||
ctxLogger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": ctxLogger.Pid,
|
||||
"FilePath": v.File,
|
||||
}).Infoln("func: ", v.FuncName, " args: ", v.Args)
|
||||
case logrus.DebugLevel:
|
||||
ctxLogger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": ctxLogger.Pid,
|
||||
"FilePath": v.File,
|
||||
}).Debugln("func: ", v.FuncName, " args: ", v.Args)
|
||||
case logrus.WarnLevel:
|
||||
ctxLogger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": ctxLogger.Pid,
|
||||
"FilePath": v.File,
|
||||
}).Warnln("func: ", v.FuncName, " args: ", v.Args)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func InfoWithCtx(ctx context.Context, args ...interface{}) {
|
||||
t := ctx.Value(tracelog.TraceLogKey).(*tracelog.FuncInfos)
|
||||
OperationID := tracelog.GetOperationID(ctx)
|
||||
for _, v := range *t.Funcs {
|
||||
logger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": logger.Pid,
|
||||
}).Infoln(v.Args, args)
|
||||
}
|
||||
}
|
||||
|
||||
func DebugWithCtx(ctx context.Context, args ...interface{}) {
|
||||
t := ctx.Value(tracelog.TraceLogKey).(*tracelog.FuncInfos)
|
||||
OperationID := tracelog.GetOperationID(ctx)
|
||||
for _, v := range *t.Funcs {
|
||||
logger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": logger.Pid,
|
||||
}).Debugln(v.Args, args)
|
||||
}
|
||||
}
|
||||
|
||||
func ErrorWithCtx(ctx context.Context, args ...interface{}) {
|
||||
t := ctx.Value(tracelog.TraceLogKey).(*tracelog.FuncInfos)
|
||||
OperationID := tracelog.GetOperationID(ctx)
|
||||
for _, v := range *t.Funcs {
|
||||
if v.Err != nil {
|
||||
logger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": logger.Pid,
|
||||
}).Errorln(v.Err, v.Args, args)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func WarnWithCtx(ctx context.Context, args ...interface{}) {
|
||||
t := ctx.Value(tracelog.TraceLogKey).(*tracelog.FuncInfos)
|
||||
OperationID := tracelog.GetOperationID(ctx)
|
||||
for _, v := range *t.Funcs {
|
||||
logger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": logger.Pid,
|
||||
}).Warnln(v.Args, args)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user