mirror of
https://github.com/datarhei/core.git
synced 2025-10-06 00:17:07 +08:00
Add config value for how many minimal process report should be kept in the history
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.
This commit is contained in:
@@ -43,12 +43,13 @@ type Parser interface {
|
||||
|
||||
// Config is the config for the Parser implementation
|
||||
type Config struct {
|
||||
LogHistory int
|
||||
LogLines int
|
||||
PreludeHeadLines int
|
||||
PreludeTailLines int
|
||||
Logger log.Logger
|
||||
Collector session.Collector
|
||||
LogLines int
|
||||
LogHistory int
|
||||
LogMinimalHistory int
|
||||
PreludeHeadLines int
|
||||
PreludeTailLines int
|
||||
Logger log.Logger
|
||||
Collector session.Collector
|
||||
}
|
||||
|
||||
type parser struct {
|
||||
@@ -75,8 +76,9 @@ type parser struct {
|
||||
logLines int
|
||||
logStart time.Time
|
||||
|
||||
logHistory *ring.Ring
|
||||
logHistoryLength int
|
||||
logHistory *ring.Ring
|
||||
logHistoryLength int
|
||||
logMinimalHistoryLength int
|
||||
|
||||
lastLogline string
|
||||
|
||||
@@ -117,10 +119,11 @@ type parser struct {
|
||||
// New returns a Parser that satisfies the Parser interface
|
||||
func New(config Config) Parser {
|
||||
p := &parser{
|
||||
logHistoryLength: config.LogHistory,
|
||||
logLines: config.LogLines,
|
||||
logger: config.Logger,
|
||||
collector: config.Collector,
|
||||
logLines: config.LogLines,
|
||||
logHistoryLength: config.LogHistory,
|
||||
logMinimalHistoryLength: config.LogMinimalHistory,
|
||||
logger: config.Logger,
|
||||
collector: config.Collector,
|
||||
}
|
||||
|
||||
if p.logger == nil {
|
||||
@@ -157,8 +160,10 @@ func New(config Config) Parser {
|
||||
p.lock.log.Lock()
|
||||
p.log = ring.New(config.LogLines)
|
||||
|
||||
if p.logHistoryLength > 0 {
|
||||
p.logHistory = ring.New(p.logHistoryLength)
|
||||
historyLength := p.logHistoryLength + p.logMinimalHistoryLength
|
||||
|
||||
if historyLength > 0 {
|
||||
p.logHistory = ring.New(historyLength)
|
||||
}
|
||||
|
||||
if p.collector == nil {
|
||||
@@ -798,6 +803,20 @@ func (p *parser) storeReportHistory(state string) {
|
||||
}
|
||||
|
||||
p.logHistory.Value = h
|
||||
|
||||
if p.logMinimalHistoryLength > 0 {
|
||||
// Remove the Log and Prelude from older history entries
|
||||
r := p.logHistory.Move(-p.logHistoryLength)
|
||||
|
||||
if r.Value != nil {
|
||||
history := r.Value.(ReportHistoryEntry)
|
||||
history.Log = nil
|
||||
history.Prelude = nil
|
||||
|
||||
r.Value = history
|
||||
}
|
||||
}
|
||||
|
||||
p.logHistory = p.logHistory.Next()
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user