From 4b243574657f9054f1b915b0102997a038fc0925 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 24 Jan 2022 17:33:39 -0700 Subject: [PATCH] move log to standard location --- README.md | 10 ++++++---- src/MinEdLauncher/Extensions.fs | 26 ++++++++++++++++++-------- src/MinEdLauncher/Log.fs | 2 +- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 8155838..70d3a8b 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ accounts on both Windows and Linux. * [Multi-Account] * [Frontier account via Steam or Epic] * [Epic account via Steam] - * [Logs] + * [Troubleshooting] * [Cache] * [Build] * [Release Artifacts] @@ -228,8 +228,10 @@ In order to authenticate with an Epic account: to include the `-auth_password=code` argument. `steam://rungameid/359320// -auth_password=code` The two trailing slashes are important. Then just edit this shortcut with the new exchange code each time instead of changing your Steam launch options. -### Logs -Debug logging is placed in the file `logs/min-ed-launcher.log` +### Troubleshooting +Debug logging is placed in the standard log location for your operating system: +* Windows - `%LOCALAPPDATA%\min-ed-launcher\min-ed-launcher.log` +* Linux - `$XDG_STATE_HOME/min-ed-launcher/min-ed-launcher.log` (`~/.local/state` if `$XDG_STATE_HOME` isn't set) ### Cache When updating your game files, the launcher downloads updates into a temporary directory. You may delete these files at any time. @@ -275,7 +277,7 @@ specifically targets Windows and won't publish on a non-Windows machine. [Multi-Account]: #multi-account [Frontier account via Steam or Epic]: #frontier-account-via-steam-or-epic [Epic account via Steam]: #epic-account-via-steam -[Logs]: #logs +[Troubleshooting]: #troubleshooting [Cache]: #cache [Build]: #build [Release Artifacts]: #release-artifacts diff --git a/src/MinEdLauncher/Extensions.fs b/src/MinEdLauncher/Extensions.fs index bd7bcfb..db50c55 100644 --- a/src/MinEdLauncher/Extensions.fs +++ b/src/MinEdLauncher/Extensions.fs @@ -471,6 +471,16 @@ module Environment = [] let private AppFolderName = "min-ed-launcher" + let private home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + let private xdgDir var fallback = + let xdgPath = Environment.GetEnvironmentVariable($"XDG_%s{var}") + if String.IsNullOrEmpty(xdgPath) then + Path.Combine(fallback, AppFolderName) + else + Path.Combine(xdgPath, AppFolderName) + let private localAppData subDir = + let appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + Path.Combine(appData, AppFolderName, subDir) let configDir = let specialFolder = @@ -484,13 +494,13 @@ module Environment = let cacheDir = if RuntimeInformation.IsOSPlatform(OSPlatform.Windows) then - let appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) - Path.Combine(appData, AppFolderName, "cache") + localAppData "cache" else - let xdgCacheHome = Environment.GetEnvironmentVariable("XDG_CACHE_HOME") - if String.IsNullOrEmpty(xdgCacheHome) then - let home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) - Path.Combine(home, ".cache", AppFolderName) - else - Path.Combine(xdgCacheHome, AppFolderName) + xdgDir "CACHE_HOME" (Path.Combine(home, ".cache")) + + let logDir = + if RuntimeInformation.IsOSPlatform(OSPlatform.Windows) then + localAppData "" + else + xdgDir "STATE_HOME" (Path.Combine(home, ".local", "state")) \ No newline at end of file diff --git a/src/MinEdLauncher/Log.fs b/src/MinEdLauncher/Log.fs index 3f25124..84c88be 100644 --- a/src/MinEdLauncher/Log.fs +++ b/src/MinEdLauncher/Log.fs @@ -52,7 +52,7 @@ type LoggerSinkConfiguration with let formatter = EpicScrubber(MessageTemplateTextFormatter("{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}", null)) this.File(formatter = formatter, path=path, restrictedToMinimumLevel=restrictedToMinimumLevel) -let logPath = Path.Combine("logs/min-ed-launcher.log") +let private logPath = Path.Combine(Environment.logDir, "min-ed-launcher.log") let logger = let consoleLevel = #if DEBUG