mirror of
https://github.com/datarhei/core.git
synced 2025-10-04 15:42:57 +08:00

A minimal history is a history entry without log and prelude. The corresponding config entry is ffmpeg.log.max_minimal_history. This value is added on top of the ffmpeg.log.max_history value. I.e. the latest max_history entries contain the log and prelude, and the remaining entries don't have the log and prelude. In total there are max_minimal_history+max_history history entries. If you want no history, set both values to 0. If you want only full history, set max_minimal_history to 0. If you want only minimal history, set max_history to 0.
75 lines
1.9 KiB
Go
75 lines
1.9 KiB
Go
package api
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/datarhei/core/v16/restream/app"
|
|
)
|
|
|
|
// ProcessReportEntry represents the logs of a run of a restream process
|
|
type ProcessReportEntry struct {
|
|
CreatedAt int64 `json:"created_at" format:"int64"`
|
|
Prelude []string `json:"prelude,omitempty"`
|
|
Log [][2]string `json:"log,omitempty"`
|
|
}
|
|
|
|
type ProcessReportHistoryEntry struct {
|
|
ProcessReportEntry
|
|
|
|
ExitedAt int64 `json:"exited_at" format:"int64"`
|
|
ExitState string `json:"exit_state"`
|
|
Progress Progress `json:"progress"`
|
|
}
|
|
|
|
// ProcessReport represents the current log and the logs of previous runs of a restream process
|
|
type ProcessReport struct {
|
|
ProcessReportEntry
|
|
History []ProcessReportHistoryEntry `json:"history"`
|
|
}
|
|
|
|
// Unmarshal converts a restream log to a report
|
|
func (report *ProcessReport) Unmarshal(l *app.Log) {
|
|
if l == nil {
|
|
return
|
|
}
|
|
|
|
report.CreatedAt = l.CreatedAt.Unix()
|
|
report.Prelude = l.Prelude
|
|
report.Log = make([][2]string, len(l.Log))
|
|
for i, line := range l.Log {
|
|
report.Log[i][0] = strconv.FormatInt(line.Timestamp.Unix(), 10)
|
|
report.Log[i][1] = line.Data
|
|
}
|
|
|
|
report.History = []ProcessReportHistoryEntry{}
|
|
|
|
for _, h := range l.History {
|
|
he := ProcessReportHistoryEntry{
|
|
ProcessReportEntry: ProcessReportEntry{
|
|
CreatedAt: h.CreatedAt.Unix(),
|
|
Prelude: h.Prelude,
|
|
Log: make([][2]string, len(h.Log)),
|
|
},
|
|
ExitedAt: h.ExitedAt.Unix(),
|
|
ExitState: h.ExitState,
|
|
}
|
|
|
|
he.Progress.Unmarshal(&h.Progress)
|
|
|
|
for i, line := range h.Log {
|
|
he.ProcessReportEntry.Log[i][0] = strconv.FormatInt(line.Timestamp.Unix(), 10)
|
|
he.ProcessReportEntry.Log[i][1] = line.Data
|
|
}
|
|
|
|
report.History = append(report.History, he)
|
|
}
|
|
}
|
|
|
|
type ProcessReportSearchResult struct {
|
|
ProcessID string `json:"id"`
|
|
Reference string `json:"reference"`
|
|
ExitState string `json:"exit_state"`
|
|
CreatedAt int64 `json:"created_at" format:"int64"`
|
|
ExitedAt int64 `json:"exited_at" format:"int64"`
|
|
}
|