Pārlūkot izejas kodu

added LogId to options and use it to create logging scope

release/3.x.x
Jan Eggers pirms 7 gadiem
vecāks
revīzija
dd447f24d2
3 mainītis faili ar 9 papildinājumiem un 1 dzēšanām
  1. +5
    -0
      MQTTnet.Core/Client/IMqttClientOptions.cs
  2. +1
    -1
      MQTTnet.Core/Client/MqttClient.cs
  3. +3
    -0
      MQTTnet.Core/Client/MqttClientOptions.cs

+ 5
- 0
MQTTnet.Core/Client/IMqttClientOptions.cs Parādīt failu

@@ -6,6 +6,11 @@ namespace MQTTnet.Core.Client
public interface IMqttClientOptions
{
string ClientId { get; }

/// <summary>
/// The LogId is used to create a scope to correlate logging. If no value is provided the ClientId is used instead
/// </summary>
string LogId { get; }
IMqttClientCredentials Credentials { get; }
bool CleanSession { get; }
MqttApplicationMessage WillMessage { get; }


+ 1
- 1
MQTTnet.Core/Client/MqttClient.cs Parādīt failu

@@ -55,7 +55,7 @@ namespace MQTTnet.Core.Client

_adapter = _communicationAdapterFactory.CreateClientMqttCommunicationAdapter(options);

_scopeHandle = _logger.BeginScope(options.ClientId);
_scopeHandle = _logger.BeginScope(options.LogId ?? options.ClientId);
_logger.LogTrace("Trying to connect with server.");
await _adapter.ConnectAsync(_options.CommunicationTimeout).ConfigureAwait(false);
_logger.LogTrace("Connection with server established.");


+ 3
- 0
MQTTnet.Core/Client/MqttClientOptions.cs Parādīt failu

@@ -9,6 +9,9 @@ namespace MQTTnet.Core.Client

public string ClientId { get; set; } = Guid.NewGuid().ToString("N");

/// <inheritdoc />
public string LogId { get; set; }

public bool CleanSession { get; set; } = true;

public IMqttClientCredentials Credentials { get; set; } = new MqttClientCredentials();


Notiek ielāde…
Atcelt
Saglabāt