Add more logs for tracing
This commit is contained in:
parent
da0c9b1b21
commit
9f8370c651
4 changed files with 9 additions and 1 deletions
|
@ -61,6 +61,7 @@ namespace NucuCar.Domain.Telemetry
|
||||||
public bool RegisterTelemeter(ITelemeter t)
|
public bool RegisterTelemeter(ITelemeter t)
|
||||||
{
|
{
|
||||||
if (RegisteredTelemeters.Contains(t)) return false;
|
if (RegisteredTelemeters.Contains(t)) return false;
|
||||||
|
Logger.LogDebug($"Registering telemeter {t.GetIdentifier()}");
|
||||||
RegisteredTelemeters.Add(t);
|
RegisteredTelemeters.Add(t);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -73,6 +74,7 @@ namespace NucuCar.Domain.Telemetry
|
||||||
public bool UnRegisterTelemeter(ITelemeter t)
|
public bool UnRegisterTelemeter(ITelemeter t)
|
||||||
{
|
{
|
||||||
if (!RegisteredTelemeters.Contains(t)) return false;
|
if (!RegisteredTelemeters.Contains(t)) return false;
|
||||||
|
Logger.LogDebug($"UnRegistering telemeter {t.GetIdentifier()}");
|
||||||
RegisteredTelemeters.Remove(t);
|
RegisteredTelemeters.Remove(t);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Iot.Device.CpuTemperature;
|
using Iot.Device.CpuTemperature;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NucuCar.Domain.Sensors;
|
using NucuCar.Domain.Sensors;
|
||||||
|
@ -52,7 +54,8 @@ namespace NucuCar.Sensors.Health
|
||||||
_lastTemperatureCelsius = double.NaN;
|
_lastTemperatureCelsius = double.NaN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Logger?.LogDebug($"{DateTimeOffset.Now}:HealthSensor: reading");
|
||||||
|
Logger.LogInformation($"CPU Temperature ${_lastTemperatureCelsius}");
|
||||||
return Task.FromResult(_lastTemperatureCelsius);
|
return Task.FromResult(_lastTemperatureCelsius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ namespace NucuCar.Sensors
|
||||||
/* If sensor is ok attempt to read. */
|
/* If sensor is ok attempt to read. */
|
||||||
if (sensorState == SensorStateEnum.Initialized)
|
if (sensorState == SensorStateEnum.Initialized)
|
||||||
{
|
{
|
||||||
|
Logger.LogTrace($"{sensorIdentifier} is taking a measurement!");
|
||||||
await Sensor.TakeMeasurementAsync();
|
await Sensor.TakeMeasurementAsync();
|
||||||
}
|
}
|
||||||
/* Else attempt to re-initialize. */
|
/* Else attempt to re-initialize. */
|
||||||
|
@ -49,6 +50,7 @@ namespace NucuCar.Sensors
|
||||||
else if (sensorState == SensorStateEnum.Disabled)
|
else if (sensorState == SensorStateEnum.Disabled)
|
||||||
{
|
{
|
||||||
// Break from while.
|
// Break from while.
|
||||||
|
Logger.LogInformation($"{sensorIdentifier} has been disabled!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ namespace NucuCar.Sensors.Telemetry
|
||||||
{
|
{
|
||||||
if (!_serviceEnabled)
|
if (!_serviceEnabled)
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("Telemetry service is disabled!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue