structured logging

This commit is contained in:
Shaun Walker
2019-10-22 11:57:28 -04:00
parent ce25967633
commit 2e3a4efb74
79 changed files with 891 additions and 497 deletions

View File

@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Authorization;
using Oqtane.Repository;
using Oqtane.Models;
using Oqtane.Shared;
using Oqtane.Infrastructure;
namespace Oqtane.Controllers
{
@ -11,10 +12,12 @@ namespace Oqtane.Controllers
public class ProfileController : Controller
{
private readonly IProfileRepository Profiles;
private readonly ILogManager logger;
public ProfileController(IProfileRepository Profiles)
public ProfileController(IProfileRepository Profiles, ILogManager logger)
{
this.Profiles = Profiles;
this.logger = logger;
}
// GET: api/<controller>?siteid=x
@ -46,6 +49,7 @@ namespace Oqtane.Controllers
if (ModelState.IsValid)
{
Profile = Profiles.AddProfile(Profile);
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Profile Added {Profile}", Profile);
}
return Profile;
}
@ -58,6 +62,7 @@ namespace Oqtane.Controllers
if (ModelState.IsValid)
{
Profile = Profiles.UpdateProfile(Profile);
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Profile Updated {Profile}", Profile);
}
return Profile;
}
@ -68,6 +73,7 @@ namespace Oqtane.Controllers
public void Delete(int id)
{
Profiles.DeleteProfile(id);
logger.AddLog(this.GetType().FullName, LogLevel.Information, "Profile Deleted {ProfileId}", id);
}
}
}