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.
41 lines
1.1 KiB
41 lines
1.1 KiB
4 years ago
|
using Microsoft.Extensions.Logging;
|
||
|
using System;
|
||
6 years ago
|
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()
|
||
|
{
|
||
4 years ago
|
Level = LogLevel.Information;
|
||
6 years ago
|
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);
|
||
|
}
|
||
|
}
|
||
|
}
|