The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
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.

LogMessage.cs 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Teknik.Utilities;
  7. namespace Teknik.Logging
  8. {
  9. public class LogMessage
  10. {
  11. public LogLevel Level { get; set; }
  12. public DateTime EntryDate { get; set; }
  13. public string Message { get; set; }
  14. public Exception Exception { get; set; }
  15. public LogMessage()
  16. {
  17. SetDefaults();
  18. }
  19. public void SetDefaults()
  20. {
  21. Level = LogLevel.Info;
  22. EntryDate = DateTime.Now;
  23. Message = string.Empty;
  24. Exception = null;
  25. }
  26. public override string ToString()
  27. {
  28. // Create the full message we want to log
  29. string fullMessage = Message;
  30. if (Exception != null)
  31. {
  32. fullMessage += " | Exception: " + Exception.GetFullMessage(true, true);
  33. }
  34. // We have rotated if needed, so let's write the entry
  35. return string.Format("{0} | {1} | {2}", Level, EntryDate.ToString("yyyy-MM-dd HH:mm:ss.fff"), fullMessage);
  36. }
  37. }
  38. }