mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-03 22:45:13 +08:00
优化日志
This commit is contained in:
@@ -297,12 +297,12 @@ func GetRpcClient(nodeId string, serviceMethod string,filterRetire bool, clientL
|
||||
if nodeId != rpc.NodeIdNull {
|
||||
pClient,retire := GetCluster().GetRpcClient(nodeId)
|
||||
if pClient == nil {
|
||||
return fmt.Errorf("cannot find nodeid %d!", nodeId), nil
|
||||
return fmt.Errorf("cannot find nodeid %s", nodeId), nil
|
||||
}
|
||||
|
||||
//如果需要筛选掉退休结点
|
||||
if filterRetire == true && retire == true {
|
||||
return fmt.Errorf("cannot find nodeid %d!", nodeId), nil
|
||||
return fmt.Errorf("cannot find nodeid %s", nodeId), nil
|
||||
}
|
||||
|
||||
clientList = append(clientList,pClient)
|
||||
|
||||
@@ -328,13 +328,13 @@ func startNode(args interface{}) error {
|
||||
myName, mErr := sysprocess.GetMyProcessName()
|
||||
//当前进程名获取失败,不应该发生
|
||||
if mErr != nil {
|
||||
log.SInfo("get my process's name is error,", mErr.Error())
|
||||
log.Info("get my process's name is error",log.ErrorAttr("err", mErr))
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
||||
//进程id存在,而且进程名也相同,被认为是当前进程重复运行
|
||||
if cErr == nil && name == myName {
|
||||
log.SInfo(fmt.Sprintf("repeat runs are not allowed,node is %s,processid is %d",strNodeId,processId))
|
||||
log.Info("repeat runs are not allowed",log.String("nodeId",strNodeId),log.Int("processId",processId))
|
||||
os.Exit(-1)
|
||||
}
|
||||
break
|
||||
|
||||
@@ -145,14 +145,12 @@ func DefaultReportFunction(name string,callNum int,costTime time.Duration,record
|
||||
return
|
||||
}
|
||||
|
||||
var strReport string
|
||||
strReport = "Profiler report tag "+name+":\n"
|
||||
var average int64
|
||||
if callNum>0 {
|
||||
average = costTime.Milliseconds()/int64(callNum)
|
||||
}
|
||||
|
||||
strReport += fmt.Sprintf("process count %d,take time %d Milliseconds,average %d Milliseconds/per.\n",callNum,costTime.Milliseconds(),average)
|
||||
log.Info("Profiler report tag "+name,log.Int("process count",callNum),log.Int64("take time",costTime.Milliseconds()),log.Int64("average",average))
|
||||
elem := record.Front()
|
||||
var strTypes string
|
||||
for elem!=nil {
|
||||
@@ -163,11 +161,9 @@ func DefaultReportFunction(name string,callNum int,costTime time.Duration,record
|
||||
strTypes = "slow process"
|
||||
}
|
||||
|
||||
strReport += fmt.Sprintf("%s:%s is take %d Milliseconds\n",strTypes,pRecord.RecordName,pRecord.CostTime.Milliseconds())
|
||||
log.Info("Profiler report type",log.String("Types",strTypes),log.String("RecordName",pRecord.RecordName),log.Int64("take time",pRecord.CostTime.Milliseconds()))
|
||||
elem = elem.Next()
|
||||
}
|
||||
|
||||
log.SInfo("report",strReport)
|
||||
}
|
||||
|
||||
func Report() {
|
||||
|
||||
@@ -90,7 +90,7 @@ func (gm *GinModule) StartTLS(certFile, keyFile string) {
|
||||
|
||||
func (gm *GinModule) Stop(ctx context.Context) {
|
||||
if err := gm.srv.Shutdown(ctx); err != nil {
|
||||
log.SError("Server Shutdown", slog.Any("error", err))
|
||||
log.Error("Server Shutdown", slog.Any("error", err))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ func Logger() gin.HandlerFunc {
|
||||
// 响应状态码
|
||||
statusCode := c.Writer.Status()
|
||||
|
||||
log.SDebug(fmt.Sprintf(
|
||||
log.Debug(fmt.Sprintf(
|
||||
"%s | %3d | %s %10s | \033[44;37m%-6s\033[0m %s %s | %10v | \"%s\" \"%s\"",
|
||||
colorForStatus(statusCode),
|
||||
statusCode,
|
||||
|
||||
Reference in New Issue
Block a user