From d469bba7b85991ce62ee75732588fb75ef232894 Mon Sep 17 00:00:00 2001 From: Chomp Date: Sun, 2 Feb 2025 17:14:57 +0000 Subject: [PATCH] Wrapped all debug logging inside `backupService` --- Libraries/Core/Services/BackupService.cs | 36 +++++++++++++----------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/Libraries/Core/Services/BackupService.cs b/Libraries/Core/Services/BackupService.cs index b5ba1302..53e1c3f7 100644 --- a/Libraries/Core/Services/BackupService.cs +++ b/Libraries/Core/Services/BackupService.cs @@ -3,6 +3,7 @@ using Core.Models.Utils; using Core.Servers; using Core.Utils; using SptCommon.Annotations; +using LogLevel = Core.Models.Spt.Logging.LogLevel; namespace Core.Services; @@ -99,7 +100,11 @@ public class BackupService if (currentProfilePaths.Count == 0) { - _logger.Debug("No profiles to backup"); + if (_logger.IsLogEnabled(LogLevel.Debug)) + { + _logger.Debug("No profiles to backup"); + } + return; } @@ -121,7 +126,10 @@ public class BackupService // Write a copy of active mods. _fileUtil.WriteFile(Path.Combine(targetDir, "activeMods.json"), _jsonUtil.Serialize(_activeServerMods)); - _logger.Debug($"Profile backup created in: {targetDir}"); + if (_logger.IsLogEnabled(LogLevel.Debug)) + { + _logger.Debug($"Profile backup created in: {targetDir}"); + } } catch (Exception ex) { @@ -132,19 +140,6 @@ public class BackupService CleanBackups(); } - /** - * Fetches the names of all JSON files in the profile directory. - * - * This method normalizes the profile directory path and reads all files within it. It then filters the files to - * include only those with a `.json` extension and returns their names. - * - * @returns A promise that resolves to a List of JSON file names. - */ - protected List FetchProfileFiles() - { - throw new NotImplementedException(); - } - /** * Check to see if the backup service is enabled via the config. * @@ -157,7 +152,10 @@ public class BackupService return true; } - _logger.Debug("Profile backups disabled"); + if (_logger.IsLogEnabled(LogLevel.Debug)) + { + _logger.Debug("Profile backups disabled"); + } return false; } @@ -298,7 +296,11 @@ public class BackupService foreach (var pathToDelete in filePathsToDelete) { _fileUtil.DeleteDirectory(Path.Combine(pathToDelete), true); - _logger.Debug($"Deleted old backup: {pathToDelete}"); + + if (_logger.IsLogEnabled(LogLevel.Debug)) + { + _logger.Debug($"Deleted old backup: {pathToDelete}"); + } } }