Add more logs for tracing

This commit is contained in:
Denis-Cosmin Nutiu 2020-01-24 14:28:48 +02:00
parent da0c9b1b21
commit 9f8370c651
4 changed files with 9 additions and 1 deletions

View file

@ -61,6 +61,7 @@ namespace NucuCar.Domain.Telemetry
public bool RegisterTelemeter(ITelemeter t)
{
if (RegisteredTelemeters.Contains(t)) return false;
Logger.LogDebug($"Registering telemeter {t.GetIdentifier()}");
RegisteredTelemeters.Add(t);
return true;
}
@ -73,6 +74,7 @@ namespace NucuCar.Domain.Telemetry
public bool UnRegisterTelemeter(ITelemeter t)
{
if (!RegisteredTelemeters.Contains(t)) return false;
Logger.LogDebug($"UnRegistering telemeter {t.GetIdentifier()}");
RegisteredTelemeters.Remove(t);
return true;
}

View file

@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Iot.Device.CpuTemperature;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using NucuCar.Domain.Sensors;
@ -52,7 +54,8 @@ namespace NucuCar.Sensors.Health
_lastTemperatureCelsius = double.NaN;
}
}
Logger?.LogDebug($"{DateTimeOffset.Now}:HealthSensor: reading");
Logger.LogInformation($"CPU Temperature ${_lastTemperatureCelsius}");
return Task.FromResult(_lastTemperatureCelsius);
}

View file

@ -34,6 +34,7 @@ namespace NucuCar.Sensors
/* If sensor is ok attempt to read. */
if (sensorState == SensorStateEnum.Initialized)
{
Logger.LogTrace($"{sensorIdentifier} is taking a measurement!");
await Sensor.TakeMeasurementAsync();
}
/* Else attempt to re-initialize. */
@ -49,6 +50,7 @@ namespace NucuCar.Sensors
else if (sensorState == SensorStateEnum.Disabled)
{
// Break from while.
Logger.LogInformation($"{sensorIdentifier} has been disabled!");
break;
}

View file

@ -30,6 +30,7 @@ namespace NucuCar.Sensors.Telemetry
{
if (!_serviceEnabled)
{
_logger.LogInformation("Telemetry service is disabled!");
return;
}