From b083ea65c047ab1faaec74a590ac61f86744d296 Mon Sep 17 00:00:00 2001 From: goaaats Date: Fri, 17 Jun 2022 17:52:43 +0200 Subject: [PATCH] feat: add verbose flag for injector --- Dalamud.Injector/EntryPoint.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Dalamud.Injector/EntryPoint.cs b/Dalamud.Injector/EntryPoint.cs index bdf20f50d..e1b0befe0 100644 --- a/Dalamud.Injector/EntryPoint.cs +++ b/Dalamud.Injector/EntryPoint.cs @@ -39,7 +39,6 @@ namespace Dalamud.Injector public static void Main(int argc, IntPtr argvPtr) { List args = new(argc); - Init(args); unsafe { @@ -48,6 +47,9 @@ namespace Dalamud.Injector args.Add(Marshal.PtrToStringUni(argv[i])); } + Init(args); + args.Remove("-v"); // Remove "verbose" flag + if (args.Count >= 2 && args[1].ToLowerInvariant() == "launch-test") { Environment.Exit(ProcessLaunchTestCommand(args)); @@ -130,8 +132,8 @@ namespace Dalamud.Injector private static void Init(List args) { + InitLogging(args.Any(x => x == "-v")); InitUnhandledException(args); - InitLogging(); var cwd = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory; if (cwd.FullName != Directory.GetCurrentDirectory()) @@ -186,16 +188,17 @@ namespace Dalamud.Injector }; } - private static void InitLogging() + private static void InitLogging(bool verbose) { - var levelSwitch = new LoggingLevelSwitch(); - #if DEBUG - levelSwitch.MinimumLevel = LogEventLevel.Verbose; -#else - levelSwitch.MinimumLevel = LogEventLevel.Information; + verbose = true; #endif + var levelSwitch = new LoggingLevelSwitch + { + MinimumLevel = verbose ? LogEventLevel.Verbose : LogEventLevel.Information, + }; + var logPath = GetLogPath("dalamud.injector"); Environment.SetEnvironmentVariable("DALAMUD_BOOT_LOGFILE", GetLogPath("dalamud.boot")); @@ -365,6 +368,8 @@ namespace Dalamud.Injector Console.WriteLine(" [--dalamud-asset-directory=path] [--dalamud-delay-initialize=0(ms)]"); Console.WriteLine(" [--dalamud-client-language=0-3|j(apanese)|e(nglish)|d|g(erman)|f(rench)]"); + Console.WriteLine("Verbose logging: [-v]"); + return 0; }