2020-08-01 14:49:20 +00:00
|
|
|
|
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 14:49:20 +00:00
|
|
|
|
|
2020-08-01 15:07:13 +00:00
|
|
|
|
namespace NucuCar.Telemetry.Publishers
|
2020-08-01 14:49:20 +00:00
|
|
|
|
{
|
|
|
|
|
public class TelemetryPublisherConsole : TelemetryPublisher
|
|
|
|
|
{
|
|
|
|
|
|
2020-08-01 15:07:13 +00:00
|
|
|
|
public TelemetryPublisherConsole(TelemetryPublisherOptions opts) : base(opts)
|
2020-08-01 14:49:20 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|