feat: allow specifying logging path via --logpath, make sure serilog can always write to injector log

This commit is contained in:
goat 2023-06-19 19:52:31 +02:00
parent b901ad5aff
commit 2e380b10d5
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
4 changed files with 40 additions and 17 deletions

View file

@ -88,13 +88,9 @@ public sealed class EntryPoint
{
var logFileName = logName.IsNullOrEmpty() ? "dalamud" : $"dalamud-{logName}";
#if DEBUG
var logPath = new FileInfo(Path.Combine(baseDirectory, $"{logFileName}.log"));
var oldPath = new FileInfo(Path.Combine(baseDirectory, $"{logFileName}.old.log"));
#else
var logPath = Path.Combine(baseDirectory, "..", "..", "..", $"{logFileName}.log");
var oldPath = Path.Combine(baseDirectory, "..", "..", "..", $"{logFileName}.old.log");
#endif
Log.CloseAndFlush();
RetentionBehaviour behaviour;
@ -137,7 +133,7 @@ public sealed class EntryPoint
private static void RunThread(DalamudStartInfo info, IntPtr mainThreadContinueEvent)
{
// Setup logger
InitLogging(info.WorkingDirectory!, info.BootShowConsole, true, info.LogName);
InitLogging(info.LogPath!, info.BootShowConsole, true, info.LogName);
SerilogEventSink.Instance.LogLine += SerilogOnLogLine;
// Load configuration first to get some early persistent state, like log level
@ -145,7 +141,7 @@ public sealed class EntryPoint
// Set the appropriate logging level from the configuration
if (!configuration.LogSynchronously)
InitLogging(info.WorkingDirectory!, info.BootShowConsole, configuration.LogSynchronously, info.LogName);
InitLogging(info.LogPath!, info.BootShowConsole, configuration.LogSynchronously, info.LogName);
LogLevelSwitch.MinimumLevel = configuration.LogLevel;
// Log any unhandled exception.