You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

44 regels
1.1 KiB

  1. using System;
  2. namespace MQTTnet.Diagnostics
  3. {
  4. public sealed class MqttNetLogMessage
  5. {
  6. public MqttNetLogMessage(string logId, DateTime timestamp, int threadId, string source, MqttNetLogLevel level, string message, Exception exception)
  7. {
  8. LogId = logId;
  9. Timestamp = timestamp;
  10. ThreadId = threadId;
  11. Source = source;
  12. Level = level;
  13. Message = message;
  14. Exception = exception;
  15. }
  16. public string LogId { get; }
  17. public DateTime Timestamp { get; }
  18. public int ThreadId { get; }
  19. public string Source { get; }
  20. public MqttNetLogLevel Level { get; }
  21. public string Message { get; }
  22. public Exception Exception { get; }
  23. public override string ToString()
  24. {
  25. var result = $"[{Timestamp:O}] [{LogId}] [{ThreadId}] [{Source}] [{Level}]: {Message}";
  26. if (Exception != null)
  27. {
  28. result += Environment.NewLine + Exception;
  29. }
  30. return result;
  31. }
  32. }
  33. }