ServerLog 打印服务相关日志信息
(serverId int64, tag string, description string, logType nodeconfigs.NodeLogType, params maps.Map)
| 246 | |
| 247 | // ServerLog 打印服务相关日志信息 |
| 248 | func ServerLog(serverId int64, tag string, description string, logType nodeconfigs.NodeLogType, params maps.Map) { |
| 249 | logs.Println("[" + tag + "]" + description) |
| 250 | |
| 251 | // 参数 |
| 252 | var paramsJSON []byte |
| 253 | if len(params) > 0 { |
| 254 | p, err := json.Marshal(params) |
| 255 | if err != nil { |
| 256 | logs.Println("[LOG]ServerLog(): json encode failed: " + err.Error()) |
| 257 | } else { |
| 258 | paramsJSON = p |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | select { |
| 263 | case logChan <- &pb.NodeLog{ |
| 264 | Role: teaconst.Role, |
| 265 | Tag: tag, |
| 266 | Description: description, |
| 267 | Level: "info", |
| 268 | NodeId: teaconst.NodeId, |
| 269 | ServerId: serverId, |
| 270 | CreatedAt: time.Now().Unix(), |
| 271 | Type: logType, |
| 272 | ParamsJSON: paramsJSON, |
| 273 | }: |
| 274 | default: |
| 275 | |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | // 上传日志 |
| 280 | func uploadLogs() error { |