Browse Source

add diff to event logs

abhishek9686 4 months ago
parent
commit
8638c47e8b
2 changed files with 3 additions and 0 deletions
  1. 2 0
      pro/logic/events.go
  2. 1 0
      schema/event.go

+ 2 - 0
pro/logic/events.go

@@ -22,6 +22,7 @@ func EventWatcher() {
 	for e := range EventActivityCh {
 		sourceJson, _ := json.Marshal(e.Source)
 		dstJson, _ := json.Marshal(e.Target)
+		diff, _ := json.Marshal(e.Diff)
 		a := schema.Event{
 			ID:          uuid.New().String(),
 			Action:      e.Action,
@@ -30,6 +31,7 @@ func EventWatcher() {
 			Origin:      e.Origin,
 			NetworkID:   e.NetworkID,
 			TriggeredBy: e.TriggeredBy,
+			Diff:        diff,
 			TimeStamp:   time.Now().UTC(),
 		}
 		a.Create(db.WithContext(context.TODO()))

+ 1 - 0
schema/event.go

@@ -17,6 +17,7 @@ type Event struct {
 	Target      datatypes.JSON   `gorm:"target" json:"target"`
 	NetworkID   models.NetworkID `gorm:"network_id" json:"network_id"`
 	TriggeredBy string           `gorm:"triggered_by" json:"triggered_by"`
+	Diff        datatypes.JSON   `gorm:"diff" json:"diff"`
 	TimeStamp   time.Time        `gorm:"time_stamp" json:"time_stamp"`
 }