Preserve process log history when updating a process

This commit is contained in:
Ingo Oppermann
2023-04-24 11:59:09 +02:00
parent d807becc8a
commit 6ddd58a124
3 changed files with 57 additions and 6 deletions

View File

@@ -33,6 +33,9 @@ type Parser interface {
// ReportHistory returns an array of previews logs
ReportHistory() []Report
// TransferReportHistory transfers the report history to another parser
TransferReportHistory(Parser) error
}
// Config is the config for the Parser implementation
@@ -767,3 +770,21 @@ func (p *parser) ReportHistory() []Report {
return history
}
func (p *parser) TransferReportHistory(dst Parser) error {
pp, ok := dst.(*parser)
if !ok {
return fmt.Errorf("the target parser is not of the required type")
}
p.logHistory.Do(func(l interface{}) {
if l == nil {
return
}
pp.logHistory.Value = l
pp.logHistory = pp.logHistory.Next()
})
return nil
}