mirror of
https://github.com/rfvgyhn/min-ed-launcher.git
synced 2026-02-04 17:15:42 +00:00
move logging to an earlier point
Log earlier so debugging is easier in the event of a runtime error
This commit is contained in:
@ -71,13 +71,11 @@ let login runningTime httpClient machineId (platform: Platform) lang =
|
||||
return result, (tokenManager :> IDisposable)
|
||||
| Error msg -> return Failure msg, noopDisposable }
|
||||
|
||||
let printInfo (platform: Platform) productsDir cobraVersion launcherVersion =
|
||||
Log.info $"""Elite Dangerous - Minimal Launcher
|
||||
Platform: %s{platform.Name}
|
||||
OS: %s{RuntimeInformation.getOsIdent()}
|
||||
CobraBay Version: %s{cobraVersion}
|
||||
Launcher Version: %s{launcherVersion}
|
||||
Products Dir: %s{productsDir}"""
|
||||
let printInfo (platform: Platform) productsDir cobraVersion =
|
||||
Log.info $"""Elite Runtime
|
||||
Platform: %s{platform.Name}
|
||||
CobraBay Version: %s{cobraVersion}
|
||||
Products Dir: %s{productsDir}"""
|
||||
|
||||
let rec launchProduct proton processArgs restart productName product =
|
||||
let args = processArgs()
|
||||
@ -280,7 +278,7 @@ let updateProduct downloader paths (manifest: Types.ProductManifest.File[]) = ta
|
||||
else
|
||||
return Ok 0 }) }
|
||||
|
||||
let run settings cancellationToken = task {
|
||||
let run settings launcherVersion cancellationToken = task {
|
||||
if RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && settings.Platform = Steam then
|
||||
Steam.fixLcAll()
|
||||
|
||||
@ -297,8 +295,8 @@ let run settings cancellationToken = task {
|
||||
| Error msg, _ -> task {
|
||||
Log.error $"Unable to get products directory: %s{msg}"
|
||||
return 1 }
|
||||
| Ok productsDir, Ok (cbVersion, launcherVersion) -> task {
|
||||
printInfo settings.Platform productsDir cbVersion launcherVersion
|
||||
| Ok productsDir, Ok cbVersion -> task {
|
||||
printInfo settings.Platform productsDir cbVersion
|
||||
use httpClient = Api.createClient settings.ApiUri launcherVersion (RuntimeInformation.getOsIdent())
|
||||
let localTime = DateTime.UtcNow
|
||||
let! remoteTime = task {
|
||||
|
||||
@ -30,9 +30,8 @@ let getVersion cbLauncherDir =
|
||||
let cobraVersion =
|
||||
let version = FileVersionInfo.GetVersionInfo(cobraPath)
|
||||
if String.IsNullOrEmpty(version.FileVersion) then version.ProductVersion else version.FileVersion
|
||||
let launcherVersion = typeof<Steam>.Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion
|
||||
|
||||
Ok (cobraVersion, launcherVersion)
|
||||
Ok cobraVersion
|
||||
|
||||
let potentialInstallPaths() =
|
||||
if RuntimeInformation.IsOSPlatform(OSPlatform.Windows) then
|
||||
|
||||
@ -8,6 +8,7 @@ open FsConfig
|
||||
open FSharp.Control.Tasks.NonAffine
|
||||
open Steam
|
||||
|
||||
let assembly = typeof<Steam>.GetTypeInfo().Assembly
|
||||
let getSettings args =
|
||||
let path = Environment.configDir
|
||||
match FileIO.ensureDirExists path with
|
||||
@ -16,7 +17,7 @@ let getSettings args =
|
||||
let settingsPath = Path.Combine(settingsDir, "settings.json")
|
||||
Log.debug $"Reading settings from '%s{settingsPath}'"
|
||||
if not (File.Exists(settingsPath)) then
|
||||
use settings = typeof<Steam>.GetTypeInfo().Assembly.GetManifestResourceStream("MinEdLauncher.settings.json")
|
||||
use settings = assembly.GetManifestResourceStream("MinEdLauncher.settings.json")
|
||||
use file = File.OpenWrite(settingsPath)
|
||||
settings.CopyTo(file)
|
||||
|> ignore
|
||||
@ -33,6 +34,13 @@ let getSettings args =
|
||||
return settings }
|
||||
| Error msg -> Error msg |> Task.fromResult
|
||||
|
||||
let logRuntimeInfo version args =
|
||||
Log.info $"Elite Dangerous: Minimal Launcher - v{version}"
|
||||
Log.debug $"""
|
||||
Args: %A{args}
|
||||
OS: %s{RuntimeInformation.getOsIdent()}
|
||||
"""
|
||||
|
||||
[<EntryPoint>]
|
||||
let main argv =
|
||||
async {
|
||||
@ -40,13 +48,15 @@ let main argv =
|
||||
|
||||
try
|
||||
do! Async.SwitchToThreadPool ()
|
||||
Log.debug $"Args: %A{argv}"
|
||||
let version = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion
|
||||
logRuntimeInfo version argv
|
||||
|
||||
let! settings = getSettings argv |> Async.AwaitTask
|
||||
Log.debug $"Settings: %A{settings}"
|
||||
return! match settings with
|
||||
| Ok settings ->
|
||||
task {
|
||||
let! runResult = App.run settings cts.Token
|
||||
let! runResult = App.run settings version cts.Token
|
||||
|
||||
if not settings.AutoQuit && not cts.Token.IsCancellationRequested then
|
||||
printfn "Press any key to quit..."
|
||||
|
||||
Reference in New Issue
Block a user