36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
|
using System;
|
|||
|
|
|||
|
namespace Plane.Logging
|
|||
|
{
|
|||
|
public abstract class Logger : ILogger
|
|||
|
{
|
|||
|
private ILogger _loggerToDecorate;
|
|||
|
|
|||
|
public Logger()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
public Logger(ILogger loggerToDecorate)
|
|||
|
{
|
|||
|
_loggerToDecorate = loggerToDecorate;
|
|||
|
}
|
|||
|
|
|||
|
public void Log(Exception ex, Priority priority = Priority.High)
|
|||
|
{
|
|||
|
Log(ex.ToString(), Category.Exception, priority);
|
|||
|
}
|
|||
|
|
|||
|
public void Log(string message, Category category = Category.Info, Priority priority = Priority.None)
|
|||
|
{
|
|||
|
_loggerToDecorate?.Log(message, category, priority);
|
|||
|
LogCore(message, category, priority);
|
|||
|
}
|
|||
|
|
|||
|
protected static string BuildStandardLogEntry(string message, Category category, Priority priority)
|
|||
|
{
|
|||
|
return $"--{category}-{priority}-{DateTime.Now.ToString("yyyyMMdd HH:mm:ss.fff")}--------------------{Environment.NewLine}{Environment.NewLine}{message}{Environment.NewLine}{Environment.NewLine}--<END>--{Environment.NewLine}{Environment.NewLine}";
|
|||
|
}
|
|||
|
|
|||
|
protected abstract void LogCore(string message, Category category, Priority priority);
|
|||
|
}
|
|||
|
}
|