mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 00:06:05 -07:00
Added the logging endpoint at /api/v1/Logging for the UI logs #1465
This commit is contained in:
parent
22aca7d2fd
commit
5f2bc4da49
3 changed files with 67 additions and 0 deletions
|
@ -84,6 +84,8 @@
|
||||||
|
|
||||||
### **Fixes**
|
### **Fixes**
|
||||||
|
|
||||||
|
- Fixed the Identity Server discovery bug #1456 #865. [tidusjar]
|
||||||
|
|
||||||
- Fixed the issue with the Identity Server running on a different port, we can now use -url #865. [Jamie.Rees]
|
- Fixed the issue with the Identity Server running on a different port, we can now use -url #865. [Jamie.Rees]
|
||||||
|
|
||||||
- Try again. [TidusJar]
|
- Try again. [TidusJar]
|
||||||
|
|
50
src/Ombi/Controllers/LoggingController.cs
Normal file
50
src/Ombi/Controllers/LoggingController.cs
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Ombi.Models;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Ombi.Controllers
|
||||||
|
{
|
||||||
|
[Authorize]
|
||||||
|
public class LoggingController : BaseV1ApiController
|
||||||
|
{
|
||||||
|
public LoggingController(ILogger logger)
|
||||||
|
{
|
||||||
|
Logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ILogger Logger { get; }
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void Log([FromBody]UiLoggingModel l)
|
||||||
|
{
|
||||||
|
l.DateTime = DateTime.UtcNow;
|
||||||
|
var exception = new Exception(l.Description, new Exception(l.StackTrace));
|
||||||
|
|
||||||
|
switch (l.Level)
|
||||||
|
{
|
||||||
|
case LogLevel.Trace:
|
||||||
|
Logger.LogTrace(new EventId(l.Id), "Exception: {0} at {1}. Stacktrade {2}", l.Description, l.Location, l.StackTrace);
|
||||||
|
break;
|
||||||
|
case LogLevel.Debug:
|
||||||
|
Logger.LogDebug(new EventId(l.Id), "Exception: {0} at {1}. Stacktrade {2}", l.Description, l.Location, l.StackTrace);
|
||||||
|
break;
|
||||||
|
case LogLevel.Information:
|
||||||
|
Logger.LogInformation(new EventId(l.Id), "Exception: {0} at {1}. Stacktrade {2}", l.Description, l.Location, l.StackTrace);
|
||||||
|
break;
|
||||||
|
case LogLevel.Warning:
|
||||||
|
Logger.LogWarning(new EventId(l.Id), "Exception: {0} at {1}. Stacktrade {2}", l.Description, l.Location, l.StackTrace);
|
||||||
|
break;
|
||||||
|
case LogLevel.Error:
|
||||||
|
Logger.LogError(new EventId(l.Id), "Exception: {0} at {1}. Stacktrade {2}", l.Description, l.Location, l.StackTrace);
|
||||||
|
break;
|
||||||
|
case LogLevel.Critical:
|
||||||
|
Logger.LogCritical(new EventId(l.Id), "Exception: {0} at {1}. Stacktrade {2}", l.Description, l.Location, l.StackTrace);
|
||||||
|
break;
|
||||||
|
case LogLevel.None:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
src/Ombi/Models/UiLoggingModel.cs
Normal file
15
src/Ombi/Models/UiLoggingModel.cs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Ombi.Models
|
||||||
|
{
|
||||||
|
public class UiLoggingModel
|
||||||
|
{
|
||||||
|
public LogLevel Level { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Location { get; set; }
|
||||||
|
public string StackTrace { get; set; }
|
||||||
|
public DateTime DateTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue