NucuCar/NucuCar.Telemetry/Publishers/TelemetryPublisherConsole.cs

29 lines
813 B
C#
Raw Normal View History

using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
2020-08-01 15:07:13 +00:00
using NucuCar.Telemetry.Abstractions;
2020-08-01 15:07:13 +00:00
namespace NucuCar.Telemetry.Publishers
{
public class TelemetryPublisherConsole : TelemetryPublisher
{
2020-08-01 15:07:13 +00:00
public TelemetryPublisherConsole(TelemetryPublisherOptions opts) : base(opts)
{
}
public override Task PublishAsync(CancellationToken cancellationToken)
{
var data = GetTelemetry();
var messageString = JsonConvert.SerializeObject(data);
Logger?.LogDebug($"Telemetry message: {messageString}");
Logger?.LogInformation(messageString);
return Task.CompletedTask;
}
public override void Dispose()
{
}
}
}