瀏覽代碼

Make string format optional if no trace listener is attached

release/3.x.x
Christian Kratky 7 年之前
父節點
當前提交
0907eadb55
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. +8
    -1
      MQTTnet.Core/Diagnostics/MqttTrace.cs

+ 8
- 1
MQTTnet.Core/Diagnostics/MqttTrace.cs 查看文件

@@ -38,7 +38,14 @@ namespace MQTTnet.Core.Diagnostics

private static void Publish(string source, MqttTraceLevel traceLevel, Exception exception, string message)
{
TraceMessagePublished?.Invoke(null, new MqttTraceMessagePublishedEventArgs(Environment.CurrentManagedThreadId, source, traceLevel, message, exception));
var handler = TraceMessagePublished;
if (handler == null)
{
return;
}

message = string.Format(message, 1);
handler.Invoke(null, new MqttTraceMessagePublishedEventArgs(Environment.CurrentManagedThreadId, source, traceLevel, message, exception));
}
}
}

Loading…
取消
儲存