From 0ecb796d54cc60612a668923cee5a9a529186758 Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Mon, 10 Jun 2024 22:04:29 +0300 Subject: [PATCH] fix: set default settings for logging if null or empty --- .../Configuration/SetupController.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Endpoint/Controllers/Configuration/SetupController.cs b/Endpoint/Controllers/Configuration/SetupController.cs index 2ccac21..67afb71 100644 --- a/Endpoint/Controllers/Configuration/SetupController.cs +++ b/Endpoint/Controllers/Configuration/SetupController.cs @@ -236,11 +236,7 @@ public class SetupController( { true => new LogSettings { - EnableLogToFile = true, - LogFileName = "log-", - LogFilePath = OperatingSystem.IsWindows() || PathBuilder.IsDefaultPath ? - PathBuilder.Combine("logs") : - "/var/log/mirea" + EnableLogToFile = true }, false => new LogSettings { @@ -250,6 +246,17 @@ public class SetupController( } }; + if (settings.EnableLogToFile) + { + if (string.IsNullOrEmpty(settings.LogFileName)) + settings.LogFileName = "log-"; + + if (string.IsNullOrEmpty(settings.LogFilePath)) + settings.LogFilePath = OperatingSystem.IsWindows() || PathBuilder.IsDefaultPath ? + PathBuilder.Combine("logs") : + "/var/log/mirea"; + } + var general = GeneralConfig; general.LogSettings = settings; GeneralConfig = general;