mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
feat: add "--console" arg to show boot console, write Dalamud logs to console if set
This commit is contained in:
parent
8cc34ea1b6
commit
c3e16ad92c
3 changed files with 16 additions and 8 deletions
|
|
@ -83,6 +83,7 @@ namespace Dalamud.Injector
|
||||||
}
|
}
|
||||||
|
|
||||||
startInfo = ExtractAndInitializeStartInfoFromArguments(startInfo, args);
|
startInfo = ExtractAndInitializeStartInfoFromArguments(startInfo, args);
|
||||||
|
args.Remove("--console"); // Remove "console" flag
|
||||||
|
|
||||||
var mainCommand = args[1].ToLowerInvariant();
|
var mainCommand = args[1].ToLowerInvariant();
|
||||||
if (mainCommand.Length > 0 && mainCommand.Length <= 6 && "inject"[..mainCommand.Length] == mainCommand)
|
if (mainCommand.Length > 0 && mainCommand.Length <= 6 && "inject"[..mainCommand.Length] == mainCommand)
|
||||||
|
|
@ -319,6 +320,7 @@ namespace Dalamud.Injector
|
||||||
startInfo.GameVersion = null;
|
startInfo.GameVersion = null;
|
||||||
|
|
||||||
// Set boot defaults
|
// Set boot defaults
|
||||||
|
startInfo.BootShowConsole = args.Contains("--console");
|
||||||
startInfo.BootLogPath = GetLogPath("dalamud.boot");
|
startInfo.BootLogPath = GetLogPath("dalamud.boot");
|
||||||
startInfo.BootEnabledGameFixes = new List<string> { "prevent_devicechange_crashes", "disable_game_openprocess_access_check", "redirect_openprocess" };
|
startInfo.BootEnabledGameFixes = new List<string> { "prevent_devicechange_crashes", "disable_game_openprocess_access_check", "redirect_openprocess" };
|
||||||
startInfo.BootDotnetOpenProcessHookMode = 0;
|
startInfo.BootDotnetOpenProcessHookMode = 0;
|
||||||
|
|
@ -356,7 +358,8 @@ namespace Dalamud.Injector
|
||||||
Console.WriteLine(" [--dalamud-asset-directory=path] [--dalamud-delay-initialize=0(ms)]");
|
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(" [--dalamud-client-language=0-3|j(apanese)|e(nglish)|d|g(erman)|f(rench)]");
|
||||||
|
|
||||||
Console.WriteLine("Verbose logging: [-v]");
|
Console.WriteLine("Verbose logging:\t[-v]");
|
||||||
|
Console.WriteLine("Show Console:\t[--console]");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
|
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||||
<PackageReference Include="Reloaded.Hooks" Version="3.5.3" />
|
<PackageReference Include="Reloaded.Hooks" Version="3.5.3" />
|
||||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.333">
|
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.333">
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ namespace Dalamud
|
||||||
private static void RunThread(DalamudStartInfo info, IntPtr mainThreadContinueEvent)
|
private static void RunThread(DalamudStartInfo info, IntPtr mainThreadContinueEvent)
|
||||||
{
|
{
|
||||||
// Setup logger
|
// Setup logger
|
||||||
var levelSwitch = InitLogging(info.WorkingDirectory);
|
var levelSwitch = InitLogging(info.WorkingDirectory, info.BootShowConsole);
|
||||||
|
|
||||||
// Load configuration first to get some early persistent state, like log level
|
// Load configuration first to get some early persistent state, like log level
|
||||||
var configuration = DalamudConfiguration.Load(info.ConfigurationPath);
|
var configuration = DalamudConfiguration.Load(info.ConfigurationPath);
|
||||||
|
|
@ -193,7 +193,7 @@ namespace Dalamud
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LoggingLevelSwitch InitLogging(string baseDirectory)
|
private static LoggingLevelSwitch InitLogging(string baseDirectory, bool logConsole)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
var logPath = Path.Combine(baseDirectory, "dalamud.log");
|
var logPath = Path.Combine(baseDirectory, "dalamud.log");
|
||||||
|
|
@ -207,11 +207,15 @@ namespace Dalamud
|
||||||
CullLogFile(oldPath, null, 10 * 1024 * 1024);
|
CullLogFile(oldPath, null, 10 * 1024 * 1024);
|
||||||
|
|
||||||
var levelSwitch = new LoggingLevelSwitch(LogEventLevel.Verbose);
|
var levelSwitch = new LoggingLevelSwitch(LogEventLevel.Verbose);
|
||||||
Log.Logger = new LoggerConfiguration()
|
var config = new LoggerConfiguration()
|
||||||
.WriteTo.Async(a => a.File(logPath, fileSizeLimitBytes: null, buffered: false, flushToDiskInterval: TimeSpan.FromSeconds(1)))
|
.WriteTo.Async(a => a.File(logPath, fileSizeLimitBytes: null, buffered: false, flushToDiskInterval: TimeSpan.FromSeconds(1)))
|
||||||
.WriteTo.Sink(SerilogEventSink.Instance)
|
.WriteTo.Sink(SerilogEventSink.Instance)
|
||||||
.MinimumLevel.ControlledBy(levelSwitch)
|
.MinimumLevel.ControlledBy(levelSwitch);
|
||||||
.CreateLogger();
|
|
||||||
|
if (logConsole)
|
||||||
|
config = config.WriteTo.Console();
|
||||||
|
|
||||||
|
Log.Logger = config.CreateLogger();
|
||||||
|
|
||||||
return levelSwitch;
|
return levelSwitch;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue