mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-03-04 14:27:52 -05:00
removed some stuff from LoggingController
This commit is contained in:
@@ -5,7 +5,7 @@ using Serilog.Events;
|
||||
namespace Executable.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
[Route("api/[controller]/level")]
|
||||
public class LoggingController : ControllerBase
|
||||
{
|
||||
private readonly LoggingConfigManager _loggingConfigManager;
|
||||
@@ -21,7 +21,7 @@ public class LoggingController : ControllerBase
|
||||
/// Gets the current global log level
|
||||
/// </summary>
|
||||
/// <returns>Current log level</returns>
|
||||
[HttpGet("level")]
|
||||
[HttpGet]
|
||||
public IActionResult GetLogLevel()
|
||||
{
|
||||
return Ok(new { level = _loggingConfigManager.GetLogLevel().ToString() });
|
||||
@@ -30,47 +30,14 @@ public class LoggingController : ControllerBase
|
||||
/// <summary>
|
||||
/// Sets the global log level
|
||||
/// </summary>
|
||||
/// <param name="request">Log level request containing the new level</param>
|
||||
/// <returns>Result with the new log level</returns>
|
||||
[HttpPut("level")]
|
||||
public async Task<IActionResult> SetLogLevel([FromBody] LogLevelRequest request)
|
||||
/// <param name="logLevel">New log level</param>
|
||||
[HttpPut]
|
||||
public async Task<IActionResult> SetLogLevel([FromBody] LogEventLevel logLevel)
|
||||
{
|
||||
if (!Enum.TryParse<LogEventLevel>(request.Level, true, out var logLevel))
|
||||
{
|
||||
return BadRequest(new
|
||||
{
|
||||
error = "Invalid log level",
|
||||
validLevels = Enum.GetNames<LogEventLevel>()
|
||||
});
|
||||
}
|
||||
|
||||
await _loggingConfigManager.SetLogLevel(logLevel);
|
||||
|
||||
// Log at the new level to confirm it's working
|
||||
_logger.WithCategory(LoggingCategoryConstants.System)
|
||||
.LogInformation("Log level changed to {Level}", logLevel);
|
||||
_logger.LogInformation("Log level changed to {level}", logLevel);
|
||||
|
||||
return Ok(new { level = logLevel.ToString() });
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of valid log levels
|
||||
/// </summary>
|
||||
/// <returns>All valid log level values</returns>
|
||||
[HttpGet("levels")]
|
||||
public IActionResult GetValidLogLevels()
|
||||
{
|
||||
return Ok(new
|
||||
{
|
||||
levels = Enum.GetNames<LogEventLevel>()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request model for changing log level
|
||||
/// </summary>
|
||||
public class LogLevelRequest
|
||||
{
|
||||
public string Level { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user