1
0
mirror of https://git.teknik.io/Teknikode/Teknik.git synced 2023-08-02 14:16:22 +02:00
Teknik/Utilities/Logging/LogMessage.cs

44 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Teknik.Utilities;
namespace Teknik.Logging
{
public class LogMessage
{
public LogLevel Level { get; set; }
public DateTime EntryDate { get; set; }
public string Message { get; set; }
public Exception Exception { get; set; }
public LogMessage()
{
SetDefaults();
}
public void SetDefaults()
{
Level = LogLevel.Info;
EntryDate = DateTime.Now;
Message = string.Empty;
Exception = null;
}
public override string ToString()
{
// Create the full message we want to log
string fullMessage = Message;
if (Exception != null)
{
fullMessage += " | Exception: " + Exception.GetFullMessage(true, true);
}
// We have rotated if needed, so let's write the entry
return string.Format("{0} | {1} | {2}", Level, EntryDate.ToString("yyyy-MM-dd HH:mm:ss.fff"), fullMessage);
}
}
}