feat: add endpoint for logging
This commit is contained in:
parent
29c9c10a53
commit
f5deeec6c9
25
ApiDto/Requests/Configuration/LoggingRequest.cs
Normal file
25
ApiDto/Requests/Configuration/LoggingRequest.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Mirea.Api.Dto.Requests.Configuration;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a request to configure logging settings.
|
||||||
|
/// </summary>
|
||||||
|
public class LoggingRequest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether logging to file is enabled.
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public bool EnableLogToFile { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the log file name.
|
||||||
|
/// </summary>
|
||||||
|
public string? LogFileName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the log file path.
|
||||||
|
/// </summary>
|
||||||
|
public string? LogFilePath { get; set; }
|
||||||
|
}
|
@ -186,6 +186,34 @@ public class SetupController(ISetupToken setupToken, IMaintenanceModeNotConfigur
|
|||||||
|
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("SetLogging")]
|
||||||
|
[TokenAuthentication]
|
||||||
|
[BadRequestResponse]
|
||||||
|
public ActionResult<bool> SetLogging([FromBody] LoggingRequest? request)
|
||||||
|
{
|
||||||
|
var settings = (request == null) switch
|
||||||
|
{
|
||||||
|
true => new LogSettings
|
||||||
|
{
|
||||||
|
EnableLogToFile = true,
|
||||||
|
LogFileName = "logging-",
|
||||||
|
LogFilePath = "logs"
|
||||||
|
},
|
||||||
|
false => new LogSettings
|
||||||
|
{
|
||||||
|
EnableLogToFile = request.EnableLogToFile,
|
||||||
|
LogFileName = request.LogFileName,
|
||||||
|
LogFilePath = request.LogFilePath
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var general = GeneralConfig;
|
||||||
|
general.LogSettings = settings;
|
||||||
|
GeneralConfig = general;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user