fix: log task start and completion details
This commit is contained in:
@@ -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)
|
logger.Error("timed task execution skipped because executor is unavailable", "task_id", taskID, "task_name", taskName, "trigger_type", trigger)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
logger.InfoContext(ctx, "timed task started", "task_id", taskID, "task_name", taskName, "trigger_type", trigger)
|
||||||
log := s.executor.Run(ctx, task, 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}
|
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 != "" {
|
if log.ErrorMsg != "" {
|
||||||
attributes = append(attributes, "error", log.ErrorMsg)
|
attributes = append(attributes, "error", log.ErrorMsg)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user