mirror of
https://github.com/datarhei/core.git
synced 2025-09-26 20:11:29 +08:00
Preserve process log history when updating a process
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user