From 68403245f0c9f8ba901f7e118307b1e45f17baf8 Mon Sep 17 00:00:00 2001 From: Max <51083570+DRdrProfessor@users.noreply.github.com> Date: Sat, 4 May 2024 14:49:32 +0200 Subject: [PATCH] Added logging building function to LogOption for creating ILogger instasnces --- DotBased/Logging/LogOptions.cs | 6 ++++++ DotBased/Logging/LogService.cs | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/DotBased/Logging/LogOptions.cs b/DotBased/Logging/LogOptions.cs index 740a9c3..850d539 100644 --- a/DotBased/Logging/LogOptions.cs +++ b/DotBased/Logging/LogOptions.cs @@ -9,4 +9,10 @@ public class LogOptions /// The severty the logger will log /// public LogSeverity Severity { get; set; } = LogSeverity.Trace; + + /// + /// The function that will build and return the when calling , so a custom logger can be used. + /// + public Func, ILogger> LoggerBuilder { get; set; } = + (identifier, source, sendEvent) => new Logger(identifier, source, ref sendEvent); } \ No newline at end of file diff --git a/DotBased/Logging/LogService.cs b/DotBased/Logging/LogService.cs index cb8813f..9822138 100644 --- a/DotBased/Logging/LogService.cs +++ b/DotBased/Logging/LogService.cs @@ -46,13 +46,12 @@ public static class LogService /// } /// /// - /// At the moment this function will only return the default class, this is not configureble at the moment! /// The identifier name of the logger, this will be passed to the log adapter as the source. - /// The configured implementation that will be configuered in the at the class + /// The configured implementation that will be configuered in the at the class public static ILogger RegisterLogger(string identifier) { var asm = Assembly.GetCallingAssembly(); - var logger = new Logger(identifier, CallingSource.LoadFromAsm(asm), ref _loggerSendEvent); + var logger = Options.LoggerBuilder.Invoke(identifier, CallingSource.LoadFromAsm(asm), _loggerSendEvent); Loggers.Add(logger); return logger; }