Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

MqttNetTrace.cs 1004 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Collections.Concurrent;
  3. using Microsoft.Extensions.Logging;
  4. namespace MQTTnet.Core.Diagnostics
  5. {
  6. public class MqttNetTrace : ILoggerProvider
  7. {
  8. private readonly ConcurrentDictionary<string, MqttNetLogger> _loggers = new ConcurrentDictionary<string, MqttNetLogger>();
  9. public static event EventHandler<MqttNetTraceMessagePublishedEventArgs> TraceMessagePublished;
  10. public void Publish(MqttNetTraceMessage msg)
  11. {
  12. TraceMessagePublished?.Invoke(this, new MqttNetTraceMessagePublishedEventArgs(msg));
  13. }
  14. public void Dispose()
  15. {
  16. TraceMessagePublished = null;
  17. }
  18. public ILogger CreateLogger(string categoryName)
  19. {
  20. return _loggers.GetOrAdd(categoryName, CreateLoggerImplementation);
  21. }
  22. private MqttNetLogger CreateLoggerImplementation(string categoryName)
  23. {
  24. return new MqttNetLogger(categoryName, this);
  25. }
  26. }
  27. }