Skip to content

Commit

Permalink
Merge pull request #1591 from pkuehnel/feat/fleetTelemetryNoLocationLog
Browse files Browse the repository at this point in the history
fix(FleetTelemetryWebSocketService): do not log locations
  • Loading branch information
pkuehnel authored Oct 30, 2024
2 parents 2212723 + 4257614 commit 2303099
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,23 @@ private async Task ReceiveMessages(ClientWebSocket webSocket, CancellationToken
{
// Decode the received message
var jsonMessage = Encoding.UTF8.GetString(buffer, 0, result.Count);
logger.LogTrace("Received message: {message}", jsonMessage);
if(jsonMessage == "Heartbeat")
{
logger.LogTrace("Received heartbeat: {message}", jsonMessage);
continue;
}
logger.LogDebug("Received non heartbeat message {string}", jsonMessage);
// Deserialize the JSON message into a C# object
var message = DeserializeFleetTelemetryMessage(jsonMessage);
if (message != null)
{
logger.LogDebug("Saving fleet telemetry message");
if (configurationWrapper.LogLocationData() ||
(message.Type != CarValueType.Latitude && message.Type != CarValueType.Longitude))
{
logger.LogDebug("Save fleet telemetry message {@message}", message);
}
else
{
logger.LogDebug("Save location message for car {carId}", carId);
}
var scope = serviceProvider.CreateScope();
var context = scope.ServiceProvider.GetRequiredService<TeslaSolarChargerContext>();
var carValueLog = new CarValueLog
Expand All @@ -177,6 +183,10 @@ private async Task ReceiveMessages(ClientWebSocket webSocket, CancellationToken
context.CarValueLogs.Add(carValueLog);
await context.SaveChangesAsync().ConfigureAwait(false);
}
else
{
logger.LogWarning("Could not deserialize non heartbeat message {string}", jsonMessage);
}
}
}
catch (Exception ex)
Expand Down

0 comments on commit 2303099

Please sign in to comment.