mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
feat: configurable log path
This commit is contained in:
parent
4264db8d67
commit
cc4a0652c2
6 changed files with 40 additions and 23 deletions
|
|
@ -115,14 +115,15 @@ namespace Dalamud.Injector
|
|||
}
|
||||
}
|
||||
|
||||
private static string GetLogPath(string filename)
|
||||
private static string GetLogPath(string fileName, string logName)
|
||||
{
|
||||
var baseDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
fileName = !string.IsNullOrEmpty(logName) ? $"{fileName}-{logName}.log" : $"{fileName}.log";
|
||||
|
||||
#if DEBUG
|
||||
var logPath = Path.Combine(baseDirectory, $"{filename}.log");
|
||||
var logPath = Path.Combine(baseDirectory, fileName);
|
||||
#else
|
||||
var logPath = Path.Combine(baseDirectory, "..", "..", "..", $"{filename}.log");
|
||||
var logPath = Path.Combine(baseDirectory, "..", "..", "..", fileName);
|
||||
#endif
|
||||
|
||||
return logPath;
|
||||
|
|
@ -130,7 +131,7 @@ namespace Dalamud.Injector
|
|||
|
||||
private static void Init(List<string> args)
|
||||
{
|
||||
InitLogging(args.Any(x => x == "-v"));
|
||||
InitLogging(args.Any(x => x == "-v"), args);
|
||||
InitUnhandledException(args);
|
||||
|
||||
var cwd = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory;
|
||||
|
|
@ -171,7 +172,7 @@ namespace Dalamud.Injector
|
|||
};
|
||||
}
|
||||
|
||||
private static void InitLogging(bool verbose)
|
||||
private static void InitLogging(bool verbose, IEnumerable<string> args)
|
||||
{
|
||||
#if DEBUG
|
||||
verbose = true;
|
||||
|
|
@ -182,7 +183,8 @@ namespace Dalamud.Injector
|
|||
MinimumLevel = verbose ? LogEventLevel.Verbose : LogEventLevel.Information,
|
||||
};
|
||||
|
||||
var logPath = GetLogPath("dalamud.injector");
|
||||
var logName = args.FirstOrDefault(x => x.StartsWith("--logname="))?[10..];
|
||||
var logPath = GetLogPath("dalamud.injector", logName);
|
||||
|
||||
CullLogFile(logPath, 1 * 1024 * 1024);
|
||||
|
||||
|
|
@ -252,11 +254,13 @@ namespace Dalamud.Injector
|
|||
var defaultPluginDirectory = startInfo.DefaultPluginDirectory;
|
||||
var assetDirectory = startInfo.AssetDirectory;
|
||||
var delayInitializeMs = startInfo.DelayInitializeMs;
|
||||
var logName = startInfo.LogName;
|
||||
var languageStr = startInfo.Language.ToString().ToLowerInvariant();
|
||||
var troubleshootingData = "{\"empty\": true, \"description\": \"No troubleshooting data supplied.\"}";
|
||||
|
||||
for (var i = 2; i < args.Count; i++)
|
||||
{
|
||||
Log.Information(args[i]);
|
||||
if (args[i].StartsWith(key = "--dalamud-working-directory="))
|
||||
workingDirectory = args[i][key.Length..];
|
||||
else if (args[i].StartsWith(key = "--dalamud-configuration-path="))
|
||||
|
|
@ -273,6 +277,8 @@ namespace Dalamud.Injector
|
|||
languageStr = args[i][key.Length..].ToLowerInvariant();
|
||||
else if (args[i].StartsWith(key = "--dalamud-tspack-b64="))
|
||||
troubleshootingData = Encoding.UTF8.GetString(Convert.FromBase64String(args[i][key.Length..]));
|
||||
else if (args[i].StartsWith(key = "--logname="))
|
||||
logName = args[i][key.Length..];
|
||||
else
|
||||
continue;
|
||||
|
||||
|
|
@ -318,11 +324,12 @@ namespace Dalamud.Injector
|
|||
startInfo.DelayInitializeMs = delayInitializeMs;
|
||||
startInfo.GameVersion = null;
|
||||
startInfo.TroubleshootingPackData = troubleshootingData;
|
||||
startInfo.LogName = logName;
|
||||
|
||||
// Set boot defaults
|
||||
startInfo.BootShowConsole = args.Contains("--console");
|
||||
startInfo.BootEnableEtw = args.Contains("--etw");
|
||||
startInfo.BootLogPath = GetLogPath("dalamud.boot");
|
||||
startInfo.BootLogPath = GetLogPath("dalamud.boot", startInfo.LogName);
|
||||
startInfo.BootEnabledGameFixes = new List<string> { "prevent_devicechange_crashes", "disable_game_openprocess_access_check", "redirect_openprocess", "backup_userdata_save", "clr_failfast_hijack" };
|
||||
startInfo.BootDotnetOpenProcessHookMode = 0;
|
||||
startInfo.BootWaitMessageBox |= args.Contains("--msgbox1") ? 1 : 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue