fix: log task start and completion details

This commit is contained in:
Yvan
2026-11-06 02:14:26 +08:00
parent 7c8148a5e5
commit 013795041b
+4
View File
@@ -316,8 +316,12 @@ func (s *TaskScheduler) run(ctx context.Context, task *taskbiz.TimedTask, trigge
logger.Error("timed task execution skipped because executor is unavailable", "task_id", taskID, "task_name", taskName, "trigger_type", trigger)
return
}
logger.InfoContext(ctx, "timed task started", "task_id", taskID, "task_name", taskName, "trigger_type", trigger)
log := s.executor.Run(ctx, task, trigger)
attributes := []any{"task_id", log.TaskID, "task_name", log.TaskName, "trigger_type", log.TriggerType, "status", log.Status, "duration_ms", log.DurationMS, "started_at", log.StartedAt, "finished_at", log.FinishedAt}
if log.Output != "" {
attributes = append(attributes, "output", log.Output)
}
if log.ErrorMsg != "" {
attributes = append(attributes, "error", log.ErrorMsg)
}