forked from Teknikode/Teknik
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.
43 lines
1.1 KiB
43 lines
1.1 KiB
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); |
|
} |
|
} |
|
}
|
|
|