structured logging
This commit is contained in:
39
Oqtane.Server/Controllers/LogController.cs
Normal file
39
Oqtane.Server/Controllers/LogController.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Oqtane.Models;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Infrastructure;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
||||
[Route("{site}/api/[controller]")]
|
||||
public class LogController : Controller
|
||||
{
|
||||
private readonly ILogManager Logger;
|
||||
private readonly ILogRepository Logs;
|
||||
|
||||
public LogController(ILogManager Logger, ILogRepository Logs)
|
||||
{
|
||||
this.Logger = Logger;
|
||||
this.Logs = Logs;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?siteid=x
|
||||
[HttpGet]
|
||||
public IEnumerable<Log> Get(string siteid)
|
||||
{
|
||||
return Logs.GetLogs(int.Parse(siteid));
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
public void Post([FromBody] Log Log)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
Logger.AddLog(Log);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user