Fix receiving proper current command args, simplifying retrieval of last log line

This commit is contained in:
Ingo Oppermann
2023-03-01 20:13:49 +01:00
parent 857f5b8182
commit cceb39192a
3 changed files with 30 additions and 29 deletions

View File

@@ -32,6 +32,9 @@ type Parser interface {
// ReportHistory returns an array of previews logs
ReportHistory() []ReportHistoryEntry
// LastLogline returns the last parsed log line
LastLogline() string
}
// Config is the config for the Parser implementation
@@ -71,6 +74,8 @@ type parser struct {
logHistory *ring.Ring
logHistoryLength int
lastLogline string
progress struct {
ffmpeg ffmpegProgress
avstream map[string]ffmpegAVstream
@@ -622,6 +627,8 @@ func (p *parser) addLog(line string) {
p.lock.log.Lock()
defer p.lock.log.Unlock()
p.lastLogline = line
p.log.Value = process.Line{
Timestamp: time.Now(),
Data: line,
@@ -646,6 +653,13 @@ func (p *parser) Log() []process.Line {
return log
}
func (p *parser) LastLogline() string {
p.lock.log.RLock()
defer p.lock.log.RUnlock()
return p.lastLogline
}
func (p *parser) ResetStats() {
p.lock.progress.Lock()
defer p.lock.progress.Unlock()