Skip to content

[Code Quality] DefaultRotationSize is duplicated between AppConfig and Logger (DRY) #845

@Christophe-Rogiers

Description

@Christophe-Rogiers

Severity: Info

Files / Lines:

  • src/Servy.Core/Config/AppConfig.cs:272public const int DefaultRotationSize = 10;
  • src/Servy.Core/Logging/Logger.cs:20public const int DefaultLogRotationSizeMB = 10;

Description:
Two separate constants both encode the same default — 10 MB log rotation size — in two different namespaces:

  • AppConfig.DefaultRotationSize is consumed by domain/mapper/CLI/options code (e.g. Servy.Core/Domain/Service.cs:133, ServiceMapper.cs:117, ServiceDtoHelper.cs:38, InstallServiceOptions.cs:45, InstallServiceCommand.cs:68, StartOptionsParser.cs:54, Servy/Mappers/ServiceConfigurationMapper.cs:35, MainViewModel.cs:835/1167/1329/1407).
  • Logger.DefaultLogRotationSizeMB is consumed by the static logger fallback path (Servy/AppBootstrapper.cs:215, Servy.CLI/Program.cs:126, Servy.Service/Service.cs:342).

Both happen to equal 10 today, but they are not linked. A future tweak to one (e.g. raising the global default to 25) leaves the other behind, and the per-service rotation default and the static-logger default silently disagree.

Suggested fix:
Pick one source of truth. Easiest is to delete Logger.DefaultLogRotationSizeMB and reference AppConfig.DefaultRotationSize directly from the three call sites. Alternatively, define Logger.DefaultLogRotationSizeMB = AppConfig.DefaultRotationSize (this works because both are const int).

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions