ServerError 打印服务相关错误信息
(serverId int64, tag string, description string, logType nodeconfigs.NodeLogType, params maps.Map)
| 174 | |
| 175 | // ServerError 打印服务相关错误信息 |
| 176 | func ServerError(serverId int64, tag string, description string, logType nodeconfigs.NodeLogType, params maps.Map) { |
| 177 | if Tea.IsTesting() { |
| 178 | logs.Println("[" + tag + "]" + description) |
| 179 | } |
| 180 | |
| 181 | // 是否记录服务相关错误 |
| 182 | nodeConfig, _ := nodeconfigs.SharedNodeConfig() |
| 183 | if nodeConfig != nil && nodeConfig.GlobalServerConfig != nil && !nodeConfig.GlobalServerConfig.Log.RecordServerError { |
| 184 | return |
| 185 | } |
| 186 | |
| 187 | // 参数 |
| 188 | var paramsJSON []byte |
| 189 | if len(params) > 0 { |
| 190 | p, err := json.Marshal(params) |
| 191 | if err != nil { |
| 192 | logs.Println("[LOG]ServerError(): json encode failed: " + err.Error()) |
| 193 | } else { |
| 194 | paramsJSON = p |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | select { |
| 199 | case logChan <- &pb.NodeLog{ |
| 200 | Role: teaconst.Role, |
| 201 | Tag: tag, |
| 202 | Description: description, |
| 203 | Level: "error", |
| 204 | NodeId: teaconst.NodeId, |
| 205 | ServerId: serverId, |
| 206 | CreatedAt: time.Now().Unix(), |
| 207 | Type: logType, |
| 208 | ParamsJSON: paramsJSON, |
| 209 | }: |
| 210 | default: |
| 211 | |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | // ServerSuccess 打印服务相关成功信息 |
| 216 | func ServerSuccess(serverId int64, tag string, description string, logType nodeconfigs.NodeLogType, params maps.Map) { |
no test coverage detected