error mgmt
This commit is contained in:
parent
ff3ac7aeb7
commit
3a0b2504f5
2 changed files with 7 additions and 4 deletions
|
@ -298,7 +298,9 @@ func /*(u types.UnixParser)*/ Parse(ctx UnixParserCtx, xp types.Event, nodes []N
|
|||
isStageOK = true
|
||||
if ParseDump {
|
||||
evtcopy := types.Event{}
|
||||
types.Clone(&event, &evtcopy)
|
||||
if err := types.Clone(&event, &evtcopy); err != nil {
|
||||
log.Fatalf("while cloning Event in parser : %s", err)
|
||||
}
|
||||
StageParseCache[stage][node.Name] = evtcopy
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,15 +96,16 @@ func ConfigureLogger(clog *log.Logger) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func Clone(a, b interface{}) {
|
||||
func Clone(a, b interface{}) error {
|
||||
|
||||
buff := new(bytes.Buffer)
|
||||
enc := gob.NewEncoder(buff)
|
||||
dec := gob.NewDecoder(buff)
|
||||
if err := enc.Encode(a); err != nil {
|
||||
log.Fatalf("failed cloning %T", a)
|
||||
return fmt.Errorf("failed cloning %T", a)
|
||||
}
|
||||
if err := dec.Decode(b); err != nil {
|
||||
log.Fatalf("failed cloning %T", b)
|
||||
return fmt.Errorf("failed cloning %T", b)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue