diff --git a/lib/utils/csvlogger.dart b/lib/utils/csvlogger.dart index 98c1f067..d5f86e34 100644 --- a/lib/utils/csvlogger.dart +++ b/lib/utils/csvlogger.dart @@ -8,7 +8,7 @@ import '../models/unit_value.dart'; import '../services/unit_conversion_service.dart'; class CSVLogger { - static const locationFields = 15; + static const locationFields = 16; static const basicFields = 3; static const operatorFields = 1; static const authFields = 0; @@ -51,6 +51,7 @@ class CSVLogger { List _logLocationMessage(LocationMessage loc) { final row = []; + row.add(_logLocationTimestamp(loc.timestamp) ?? ''); row.add(loc.status.asString() ?? ''); row.add(loc.location?.latitude ?? ''); row.add(loc.location?.longitude ?? ''); @@ -253,9 +254,10 @@ class CSVLogger { // common 'Message Type', 'Message Source', - 'Timestamp', + 'Received Timestamp', 'Mac Address', // location + 'Location Timestamp', 'Status', 'Latitude', 'Longitude', @@ -293,4 +295,12 @@ class CSVLogger { 'Category', 'Class Value', ]; + + // log in format hh:mm:ss.sss + String? _logLocationTimestamp(Duration? duration) { + if (duration == null) return null; + // toString uses format H:MM:SS.mmmmmm, remove last 3 digits + final durationString = duration.toString(); + return durationString.substring(0, durationString.length - 3); + } }