logging abstraction

This commit is contained in:
Shaun Walker
2019-10-26 11:00:45 -04:00
parent f59ec7bdac
commit e25bbe2e24
23 changed files with 79 additions and 72 deletions

View File

@ -25,12 +25,12 @@ namespace Oqtane.Infrastructure
this.Accessor = Accessor;
}
public void Log(LogLevel Level, string Category, LogFunction Function, string Message, params object[] Args)
public void Log(LogLevel Level, object Class, LogFunction Function, string Message, params object[] Args)
{
Log(Level, Category, Function, null, Message, Args);
Log(Level, Class.GetType().AssemblyQualifiedName, Function, null, Message, Args);
}
public void Log(LogLevel Level, string Category, LogFunction Function, Exception Exception, string Message, params object[] Args)
public void Log(LogLevel Level, object Class, LogFunction Function, Exception Exception, string Message, params object[] Args)
{
Alias alias = TenantResolver.GetAlias();
Log log = new Log();
@ -47,8 +47,15 @@ namespace Oqtane.Infrastructure
log.Url = request.Scheme.ToString() + "://" + request.Host.ToString() + request.Path.ToString() + request.QueryString.ToString();
}
log.Category = Category;
log.Feature = Utilities.GetTypeNameLastSegment(Category, 0);
if (Class.GetType() != null)
{
log.Category = Class.GetType().AssemblyQualifiedName;
}
else
{
log.Category = Class.ToString();
}
log.Feature = Utilities.GetTypeNameLastSegment(log.Category, 0);
log.Function = Enum.GetName(typeof(LogFunction), Function);
log.Level = Enum.GetName(typeof(LogLevel), Level);
if (Exception != null)