diff --git a/backend/pkg/logger/data/logger.go b/backend/pkg/logger/data/logger.go index 566a9dcbc..4198b18c7 100644 --- a/backend/pkg/logger/data/logger.go +++ b/backend/pkg/logger/data/logger.go @@ -137,8 +137,9 @@ func (sublogger *Logger) getFile(valueName data.ValueName) (*file.CSV, error) { func (sublogger *Logger) createFile(valueName data.ValueName) (*os.File, error) { filename := path.Join( - "logger", "data", + "logger", loggerHandler.Timestamp.Format(loggerHandler.TimestampFormat), + "data", fmt.Sprintf("%s.csv", valueName), ) diff --git a/backend/pkg/logger/order/logger.go b/backend/pkg/logger/order/logger.go index 1a58cfeea..07828ffcd 100644 --- a/backend/pkg/logger/order/logger.go +++ b/backend/pkg/logger/order/logger.go @@ -59,8 +59,9 @@ func (sublogger *Logger) Start() error { func (sublogger *Logger) createFile() (*os.File, error) { filename := path.Join( - "logger", "order", + "logger", logger.Timestamp.Format(logger.TimestampFormat), + "order", "order.csv", ) diff --git a/backend/pkg/logger/protection/logger.go b/backend/pkg/logger/protection/logger.go index ae1d1c2e7..bd93f62d8 100644 --- a/backend/pkg/logger/protection/logger.go +++ b/backend/pkg/logger/protection/logger.go @@ -118,8 +118,9 @@ func (sublogger *Logger) createFile(boardId abstraction.BoardId) (*os.File, erro } filename := path.Join( - "logger", "protections", + "logger", logger.Timestamp.Format(logger.TimestampFormat), + "protections", fmt.Sprintf("%s.csv", boardName), ) diff --git a/backend/pkg/logger/state/logger.go b/backend/pkg/logger/state/logger.go index cc04030fe..a4459c0b8 100644 --- a/backend/pkg/logger/state/logger.go +++ b/backend/pkg/logger/state/logger.go @@ -94,8 +94,9 @@ func (sublogger *Logger) PushRecord(record abstraction.LoggerRecord) error { func (sublogger *Logger) createFile(timestamp time.Time) (*file.CSV, error) { filename := path.Join( - "logger", "state", + "logger", logger.Timestamp.Format(logger.TimestampFormat), + "state", fmt.Sprintf("%s.csv", timestamp.Format(logger.TimestampFormat)), ) diff --git a/backend/pkg/vehicle/notification.go b/backend/pkg/vehicle/notification.go index 578463c8b..7fcbd016b 100644 --- a/backend/pkg/vehicle/notification.go +++ b/backend/pkg/vehicle/notification.go @@ -43,6 +43,8 @@ func (vehicle *Vehicle) Notification(notification abstraction.TransportNotificat } func (vehicle *Vehicle) handlePacketNotification(notification transport.PacketNotification) error { + var from string + var to string switch p := notification.Packet.(type) { case *data.Packet: @@ -53,10 +55,25 @@ func (vehicle *Vehicle) handlePacketNotification(notification transport.PacketNo return errors.Join(fmt.Errorf("update data to frontend (data with id %d from %s to %s)", p.Id(), notification.From, notification.To), err) } + from_ip := strings.Split(notification.From, ":")[0] + to_ip := strings.Split(notification.To, ":")[0] + + if from_ip == "192.168.0.9" { + from = "backend" + } else { + from = vehicle.idToBoardName[uint16(vehicle.ipToBoardId[from_ip])] + } + + if to_ip == "192.168.0.9" { + to = "backend" + } else { + to = vehicle.idToBoardName[uint16(vehicle.ipToBoardId[to_ip])] + } + err = vehicle.logger.PushRecord(&data_logger.Record{ Packet: p, - From: notification.From, - To: notification.To, + From: from, + To: to, Timestamp: notification.Timestamp, })