From b9aa2d50df76bd16083c2f7a5726a8ca0c79c949 Mon Sep 17 00:00:00 2001 From: Jianjun Liao Date: Mon, 23 Dec 2024 14:28:10 +0800 Subject: [PATCH] add status field for log status with json Signed-off-by: Jianjun Liao --- br/pkg/stream/stream_status.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/br/pkg/stream/stream_status.go b/br/pkg/stream/stream_status.go index d5aeb74b52cf0..2fd10b130975d 100644 --- a/br/pkg/stream/stream_status.go +++ b/br/pkg/stream/stream_status.go @@ -97,6 +97,16 @@ func (t *TaskStatus) colorfulStatusString() string { return statusOK("NORMAL") } +func (t *TaskStatus) statusString() string { + if t.paused && len(t.LastErrors) > 0 { + return "ERROR" + } + if t.paused { + return "PAUSE" + } + return "NORMAL" +} + // GetCheckpoint calculates the checkpoint of the task. func (t TaskStatus) GetMinStoreCheckpoint() Checkpoint { initialized := false @@ -194,6 +204,7 @@ func (p *printByJSON) PrintTasks() { Name string `json:"name"` StartTS uint64 `json:"start_ts,omitempty"` EndTS uint64 `json:"end_ts,omitempty"` + Status string `json:"status"` TableFilter []string `json:"table_filter"` Progress []storeProgress `json:"progress"` Storage string `json:"storage"` @@ -223,6 +234,7 @@ func (p *printByJSON) PrintTasks() { Name: t.Info.GetName(), StartTS: t.Info.GetStartTs(), EndTS: t.Info.GetEndTs(), + Status: t.statusString(), TableFilter: t.Info.GetTableFilter(), Progress: sp, Storage: s.String(),