Files
EonaCat.Logger/EonaCat.Logger/LoggerConfigurator.cs
Jeroen Saey a090ea8e47 Updated
2026-02-06 09:49:27 +01:00

44 lines
2.1 KiB
C#

using EonaCat.Logger.EonaCatCoreLogger;
namespace EonaCat.Logger
{
public static class LoggerConfigurator
{
/// <summary>
/// Copies file logger settings from the specified source options to the target options instance.
/// </summary>
/// <remarks>Only properties defined in FileLoggerOptions are copied. The method does not perform
/// a deep clone; reference-type properties are assigned directly. If either parameter is null, the method
/// returns without making changes.</remarks>
/// <param name="target">The FileLoggerOptions instance to which settings will be applied. If null, no changes are made.</param>
/// <param name="source">The FileLoggerOptions instance from which settings are copied. If null, no changes are made.</param>
public static void ApplyFileLoggerSettings(FileLoggerOptions target, FileLoggerOptions source)
{
if (target == null || source == null)
{
return;
}
target.FileNamePrefix = source.FileNamePrefix;
target.FlushPeriod = source.FlushPeriod;
target.RetainedFileCountLimit = source.RetainedFileCountLimit;
target.MaxWriteTries = source.MaxWriteTries;
target.FileSizeLimit = source.FileSizeLimit;
target.IsEnabled = source.IsEnabled;
target.MaxRolloverFiles = source.MaxRolloverFiles;
target.UseLocalTime = source.UseLocalTime;
target.UseMask = source.UseMask;
target.Mask = source.Mask;
target.UseDefaultMasking = source.UseDefaultMasking;
target.MaskedKeywords = source.MaskedKeywords;
target.IncludeCorrelationId = source.IncludeCorrelationId;
target.EnableCategoryRouting = source.EnableCategoryRouting;
target.Category = source.Category;
target.LogDirectory = source.LogDirectory;
target.BatchSize = source.BatchSize;
target.Settings = source.Settings;
target.LoggerSettings = source.LoggerSettings;
}
}
}