mirror of
https://github.com/garraflavatra/rolens.git
synced 2025-01-18 21:17:59 +00:00
Write environment info to JSON file
This commit is contained in:
parent
82d880dbff
commit
8319f0bd82
@ -2,10 +2,12 @@ package app
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
@ -83,6 +85,15 @@ func (a *App) Startup(ctx context.Context, ui *ui.UI) {
|
|||||||
a.Env.Arch = wailsEnv.Arch
|
a.Env.Arch = wailsEnv.Arch
|
||||||
a.Env.BuildType = wailsEnv.BuildType
|
a.Env.BuildType = wailsEnv.BuildType
|
||||||
a.Env.Platform = wailsEnv.Platform
|
a.Env.Platform = wailsEnv.Platform
|
||||||
|
|
||||||
|
jsonEnv, err := json.MarshalIndent(a.Env, "", " ")
|
||||||
|
if err != nil {
|
||||||
|
wailsRuntime.LogWarningf(a.ctx, "Could not marshal environment info: %s", err.Error())
|
||||||
|
}
|
||||||
|
err = os.WriteFile(path.Join(a.Env.LogDirectory, "environment.json"), jsonEnv, 0644)
|
||||||
|
if err != nil {
|
||||||
|
wailsRuntime.LogWarningf(a.ctx, "Could not save environment.json: %s", err.Error())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) Shutdown(ctx context.Context) {
|
func (a *App) Shutdown(ctx context.Context) {
|
||||||
@ -109,5 +120,5 @@ func (a *App) PurgeLogDirectory() {
|
|||||||
|
|
||||||
func (a *App) ReportSharedStateVariable(key, value string) {
|
func (a *App) ReportSharedStateVariable(key, value string) {
|
||||||
a.State[key] = value
|
a.State[key] = value
|
||||||
wailsRuntime.LogDebug(a.ctx, fmt.Sprintf("State has been reported: %s=\"%s\"", key, value))
|
wailsRuntime.LogDebug(a.ctx, fmt.Sprintf("State: %s=\"%s\"", key, value))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user