task_log.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package service
  2. import (
  3. "context"
  4. "time"
  5. "go-common/app/job/main/aegis/model"
  6. "go-common/library/log"
  7. "go-common/library/queue/databus/report"
  8. )
  9. // send to log service
  10. func (s *Service) sendTaskLog(c context.Context, task *model.Task, tp int, action string, uid int64, uname string) (err error) {
  11. logData := &report.ManagerInfo{
  12. UID: uid,
  13. Uname: uname,
  14. Business: model.LogBusinessTask,
  15. Type: tp,
  16. Oid: task.ID,
  17. Action: action,
  18. Ctime: time.Now(),
  19. Index: []interface{}{task.BusinessID, task.FlowID, task.State},
  20. Content: map[string]interface{}{
  21. "task": task,
  22. },
  23. }
  24. err = report.Manager(logData)
  25. log.Info("sendTaskLog logData(%+v) errmsg(%v)", logData, err)
  26. return
  27. }
  28. func (s *Service) sendWeightLog(c context.Context, task *model.Task, wl *model.WeightLog) (err error) {
  29. logData := &report.ManagerInfo{
  30. UID: 399,
  31. Uname: "aegis-job",
  32. Business: model.LogBusinessTask,
  33. Type: model.LogTYpeTaskWeight,
  34. Oid: task.ID,
  35. Action: "weight",
  36. Ctime: time.Now(),
  37. Index: []interface{}{task.BusinessID, task.FlowID, task.State},
  38. Content: map[string]interface{}{
  39. "weightlog": wl,
  40. },
  41. }
  42. err = report.Manager(logData)
  43. log.Info("sendWeightLog logData(%+v) errmsg(%v)", logData, err)
  44. return
  45. }