From 281bcb28fe967bb240310b0334edd97d8c2e3d5b Mon Sep 17 00:00:00 2001 From: martylukyy <35452459+martylukyy@users.noreply.github.com> Date: Mon, 19 Aug 2024 03:59:43 +0200 Subject: [PATCH] New: Configure log file size limit in UI (cherry picked from commit 35baebaf7280749d5dfe5440e28b425e45a22d21) Closes #5023 --- .../src/Settings/General/GeneralSettings.js | 1 + .../src/Settings/General/LoggingSettings.js | 23 ++++++++++++++++++- .../Config/HostConfigController.cs | 2 ++ .../Config/HostConfigResource.cs | 2 ++ src/NzbDrone.Core/Localization/Core/en.json | 2 ++ 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/frontend/src/Settings/General/GeneralSettings.js b/frontend/src/Settings/General/GeneralSettings.js index 91e7287ee..39340c856 100644 --- a/frontend/src/Settings/General/GeneralSettings.js +++ b/frontend/src/Settings/General/GeneralSettings.js @@ -156,6 +156,7 @@ class GeneralSettings extends Component { /> diff --git a/frontend/src/Settings/General/LoggingSettings.js b/frontend/src/Settings/General/LoggingSettings.js index 93918a3d2..043867853 100644 --- a/frontend/src/Settings/General/LoggingSettings.js +++ b/frontend/src/Settings/General/LoggingSettings.js @@ -15,12 +15,14 @@ const logLevelOptions = [ function LoggingSettings(props) { const { + advancedSettings, settings, onInputChange } = props; const { - logLevel + logLevel, + logSizeLimit } = settings; return ( @@ -39,11 +41,30 @@ function LoggingSettings(props) { {...logLevel} /> + + + {translate('LogSizeLimit')} + + + ); } LoggingSettings.propTypes = { + advancedSettings: PropTypes.bool.isRequired, settings: PropTypes.object.isRequired, onInputChange: PropTypes.func.isRequired }; diff --git a/src/Lidarr.Api.V1/Config/HostConfigController.cs b/src/Lidarr.Api.V1/Config/HostConfigController.cs index 3184a1a83..ca3f88fc2 100644 --- a/src/Lidarr.Api.V1/Config/HostConfigController.cs +++ b/src/Lidarr.Api.V1/Config/HostConfigController.cs @@ -61,6 +61,8 @@ namespace Lidarr.Api.V1.Config .Must((resource, path) => IsValidSslCertificate(resource)).WithMessage("Invalid SSL certificate file or password") .When(c => c.EnableSsl); + SharedValidator.RuleFor(c => c.LogSizeLimit).InclusiveBetween(1, 10); + SharedValidator.RuleFor(c => c.Branch).NotEmpty().WithMessage("Branch name is required, 'master' is the default"); SharedValidator.RuleFor(c => c.UpdateScriptPath).IsValidPath().When(c => c.UpdateMechanism == UpdateMechanism.Script); diff --git a/src/Lidarr.Api.V1/Config/HostConfigResource.cs b/src/Lidarr.Api.V1/Config/HostConfigResource.cs index 9182901cb..596b77c73 100644 --- a/src/Lidarr.Api.V1/Config/HostConfigResource.cs +++ b/src/Lidarr.Api.V1/Config/HostConfigResource.cs @@ -21,6 +21,7 @@ namespace Lidarr.Api.V1.Config public string Password { get; set; } public string PasswordConfirmation { get; set; } public string LogLevel { get; set; } + public int LogSizeLimit { get; set; } public string ConsoleLogLevel { get; set; } public string Branch { get; set; } public string ApiKey { get; set; } @@ -65,6 +66,7 @@ namespace Lidarr.Api.V1.Config // Username // Password LogLevel = model.LogLevel, + LogSizeLimit = model.LogSizeLimit, ConsoleLogLevel = model.ConsoleLogLevel, Branch = model.Branch, ApiKey = model.ApiKey, diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index 4ef39994c..abdd53139 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -666,6 +666,8 @@ "LogFiles": "Log Files", "LogLevel": "Log Level", "LogLevelvalueTraceTraceLoggingShouldOnlyBeEnabledTemporarily": "Trace logging should only be enabled temporarily", + "LogSizeLimit": "Log Size Limit", + "LogSizeLimitHelpText": "Maximum log file size in MB before archiving. Default is 1MB.", "Logging": "Logging", "Logout": "Logout", "Logs": "Logs",