From 9e3dd9be0f0ec7aaef1a719f09f96425e66369df Mon Sep 17 00:00:00 2001 From: vnugent Date: Thu, 2 Nov 2023 01:49:02 -0400 Subject: may have gottem carried away --- lib/Plugins.PluginBase/src/PluginBase.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'lib/Plugins.PluginBase/src/PluginBase.cs') diff --git a/lib/Plugins.PluginBase/src/PluginBase.cs b/lib/Plugins.PluginBase/src/PluginBase.cs index bb42c97..839e331 100644 --- a/lib/Plugins.PluginBase/src/PluginBase.cs +++ b/lib/Plugins.PluginBase/src/PluginBase.cs @@ -106,6 +106,11 @@ namespace VNLib.Plugins /// protected virtual string LogTemplate => $"{{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}} [{{Level:u3}}] {PluginName}: {{Message:lj}}{{NewLine}}{{Exception}}"; + /// + /// Arguments passed to the plugin by the host application + /// + public ArgumentList HostArgs { get; private set; } + /// /// The host application may invoke this method when the assembly is loaded and this plugin is constructed to pass /// a configuration object to the instance. This method populates the configuration objects if applicable. @@ -133,16 +138,16 @@ namespace VNLib.Plugins [LogInitializer] public virtual void InitLog(string[] cmdArgs) { - ArgumentList args = new(cmdArgs); + HostArgs = new(cmdArgs); //Open new logger config LoggerConfiguration logConfig = new(); //Check for verbose - if (args.HasArgument("-v")) + if (HostArgs.HasArgument("-v")) { logConfig.MinimumLevel.Verbose(); } //Check for debug mode - else if (args.HasArgument("-d")) + else if (HostArgs.HasArgument("-d")) { logConfig.MinimumLevel.Debug(); } @@ -153,7 +158,7 @@ namespace VNLib.Plugins } //Init console log - InitConsoleLog(args, logConfig); + InitConsoleLog(logConfig); //Init file log InitFileLog(logConfig); @@ -162,10 +167,10 @@ namespace VNLib.Plugins Log = new VLogProvider(logConfig); } - private void InitConsoleLog(ArgumentList args, LoggerConfiguration logConfig) + private void InitConsoleLog(LoggerConfiguration logConfig) { //If silent arg is not specified, open log to console - if (!(args.HasArgument("--silent") || args.HasArgument("-s"))) + if (!(HostArgs.HasArgument("--silent") || HostArgs.HasArgument("-s"))) { _ = logConfig.WriteTo.Console(outputTemplate: LogTemplate, formatProvider:null); } -- cgit