diff --git a/NucuCar.Sensors/Modules/PMS5003/Pms5003Sensor.cs b/NucuCar.Sensors/Modules/PMS5003/Pms5003Sensor.cs index c8f6d76..10b9e63 100644 --- a/NucuCar.Sensors/Modules/PMS5003/Pms5003Sensor.cs +++ b/NucuCar.Sensors/Modules/PMS5003/Pms5003Sensor.cs @@ -11,6 +11,7 @@ namespace NucuCar.Sensors.Modules.PMS5003 { public class Pms5003Sensor : GenericTelemeterSensor, IDisposable, ISensor { + private readonly ILoggerFactory _loggerFactory; private Pms5003 _pms5003; private Pms5003Data _pms5003Data; @@ -18,16 +19,17 @@ namespace NucuCar.Sensors.Modules.PMS5003 { } - public Pms5003Sensor(ILogger logger, IOptions options) + public Pms5003Sensor(ILoggerFactory loggingFactory, IOptions options) { CurrentState = SensorStateEnum.Uninitialized; - Logger = logger; + Logger = loggingFactory.CreateLogger(nameof(Pms5003Sensor)); if (!options.Value.Enabled) { Logger?.LogDebug("Pms5003 Sensor is disabled!"); CurrentState = SensorStateEnum.Disabled; } - + + _loggerFactory = loggingFactory; TelemetryEnabled = options.Value.Telemetry; } @@ -41,7 +43,7 @@ namespace NucuCar.Sensors.Modules.PMS5003 try { - Pms5003.Logger = (Logger) Logger; + Pms5003.Logger = new Logger(_loggerFactory); _pms5003 = new Pms5003(23, 24); _pms5003.Reset(); CurrentState = SensorStateEnum.Initialized; diff --git a/NucuCar.Telemetry/TelemetryPublisherProxy.cs b/NucuCar.Telemetry/TelemetryPublisherProxy.cs index 61b953e..86b890f 100644 --- a/NucuCar.Telemetry/TelemetryPublisherProxy.cs +++ b/NucuCar.Telemetry/TelemetryPublisherProxy.cs @@ -9,7 +9,8 @@ namespace NucuCar.Telemetry { public class TelemetryPublisherProxy : ITelemetryPublisher { - private ITelemetryPublisher Publisher { get; set; } + // TODO: Add support for chaining publishers. + private ITelemetryPublisher Publisher { get; } /// /// Class used together with the DI, holds a Publisher instance that's being create by options from