1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-27 02:43:57 +02:00

New: Configure log file size limit in UI

This commit is contained in:
martylukyy 2024-08-19 03:59:43 +02:00 committed by GitHub
parent aedcd046fc
commit 35baebaf72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 33 additions and 1 deletions

View File

@ -157,6 +157,7 @@ class GeneralSettings extends Component {
/> />
<LoggingSettings <LoggingSettings
advancedSettings={advancedSettings}
settings={settings} settings={settings}
onInputChange={onInputChange} onInputChange={onInputChange}
/> />

View File

@ -30,12 +30,14 @@ const logLevelOptions = [
function LoggingSettings(props) { function LoggingSettings(props) {
const { const {
advancedSettings,
settings, settings,
onInputChange onInputChange
} = props; } = props;
const { const {
logLevel logLevel,
logSizeLimit
} = settings; } = settings;
return ( return (
@ -52,11 +54,30 @@ function LoggingSettings(props) {
{...logLevel} {...logLevel}
/> />
</FormGroup> </FormGroup>
<FormGroup
advancedSettings={advancedSettings}
isAdvanced={true}
>
<FormLabel>{translate('LogSizeLimit')}</FormLabel>
<FormInputGroup
type={inputTypes.NUMBER}
name="logSizeLimit"
min={1}
max={10}
unit="MB"
helpText={translate('LogSizeLimitHelpText')}
onChange={onInputChange}
{...logSizeLimit}
/>
</FormGroup>
</FieldSet> </FieldSet>
); );
} }
LoggingSettings.propTypes = { LoggingSettings.propTypes = {
advancedSettings: PropTypes.bool.isRequired,
settings: PropTypes.object.isRequired, settings: PropTypes.object.isRequired,
onInputChange: PropTypes.func.isRequired onInputChange: PropTypes.func.isRequired
}; };

View File

@ -1097,6 +1097,8 @@
"LogLevel": "Log Level", "LogLevel": "Log Level",
"LogLevelTraceHelpTextWarning": "Trace logging should only be enabled temporarily", "LogLevelTraceHelpTextWarning": "Trace logging should only be enabled temporarily",
"LogOnly": "Log Only", "LogOnly": "Log Only",
"LogSizeLimit": "Log Size Limit",
"LogSizeLimitHelpText": "Maximum log file size in MB before archiving. Default is 1MB.",
"Logging": "Logging", "Logging": "Logging",
"Logout": "Logout", "Logout": "Logout",
"Logs": "Logs", "Logs": "Logs",

View File

@ -61,6 +61,8 @@ public HostConfigController(IConfigFileProvider configFileProvider,
.Must((resource, path) => IsValidSslCertificate(resource)).WithMessage("Invalid SSL certificate file or password") .Must((resource, path) => IsValidSslCertificate(resource)).WithMessage("Invalid SSL certificate file or password")
.When(c => c.EnableSsl); .When(c => c.EnableSsl);
SharedValidator.RuleFor(c => c.LogSizeLimit).InclusiveBetween(1, 10);
SharedValidator.RuleFor(c => c.Branch).NotEmpty().WithMessage("Branch name is required, 'main' is the default"); SharedValidator.RuleFor(c => c.Branch).NotEmpty().WithMessage("Branch name is required, 'main' is the default");
SharedValidator.RuleFor(c => c.UpdateScriptPath).IsValidPath().When(c => c.UpdateMechanism == UpdateMechanism.Script); SharedValidator.RuleFor(c => c.UpdateScriptPath).IsValidPath().When(c => c.UpdateMechanism == UpdateMechanism.Script);

View File

@ -21,6 +21,7 @@ public class HostConfigResource : RestResource
public string Password { get; set; } public string Password { get; set; }
public string PasswordConfirmation { get; set; } public string PasswordConfirmation { get; set; }
public string LogLevel { get; set; } public string LogLevel { get; set; }
public int LogSizeLimit { get; set; }
public string ConsoleLogLevel { get; set; } public string ConsoleLogLevel { get; set; }
public string Branch { get; set; } public string Branch { get; set; }
public string ApiKey { get; set; } public string ApiKey { get; set; }
@ -65,6 +66,7 @@ public static HostConfigResource ToResource(this IConfigFileProvider model, ICon
// Username // Username
// Password // Password
LogLevel = model.LogLevel, LogLevel = model.LogLevel,
LogSizeLimit = model.LogSizeLimit,
ConsoleLogLevel = model.ConsoleLogLevel, ConsoleLogLevel = model.ConsoleLogLevel,
Branch = model.Branch, Branch = model.Branch,
ApiKey = model.ApiKey, ApiKey = model.ApiKey,

View File

@ -8858,6 +8858,10 @@
"type": "string", "type": "string",
"nullable": true "nullable": true
}, },
"logSizeLimit": {
"type": "integer",
"nullable": true
},
"consoleLogLevel": { "consoleLogLevel": {
"type": "string", "type": "string",
"nullable": true "nullable": true