Skip to content

Commit 5a4d8eb

Browse files
committed
Open log file function
1 parent 3ac4fa9 commit 5a4d8eb

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

app.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package main
33
import (
44
"context"
55
"os"
6+
"os/exec"
67
"path/filepath"
8+
goruntime "runtime"
79
"sync"
810

911
"github.com/fogleman/delaunay"
@@ -295,6 +297,27 @@ func (a *App) GetTriangles() []Triangle {
295297
return []Triangle{}
296298
}
297299

300+
func (a *App) OpenLogFile() error {
301+
exePath, err := os.Executable()
302+
if err != nil {
303+
exePath = "."
304+
} else {
305+
exePath = filepath.Dir(exePath)
306+
}
307+
logPath := filepath.Join(exePath, "folje_log.txt")
308+
309+
var cmd *exec.Cmd
310+
switch goruntime.GOOS {
311+
case "darwin":
312+
cmd = exec.Command("open", logPath)
313+
case "windows":
314+
cmd = exec.Command("cmd", "/c", "start", "", logPath)
315+
default:
316+
cmd = exec.Command("xdg-open", logPath)
317+
}
318+
return cmd.Start()
319+
}
320+
298321
func (a *App) Log(message string) {
299322
LogInfo("[Frontend] %s", message)
300323
}

frontend/src/App.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,9 @@
10501050
<input type="checkbox" bind:checked={showTriangles} />
10511051
Draw Triangles
10521052
</label>
1053+
<button on:click={() => App.OpenLogFile()}>
1054+
Open Log
1055+
</button>
10531056
</div>
10541057
</details>
10551058
</div>

frontend/wailsjs/go/main/App.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export function LoadFileFromPath(arg1:string):Promise<string>;
1818

1919
export function Log(arg1:string):Promise<void>;
2020

21+
export function OpenLogFile():Promise<void>;
22+
2123
export function SaveFile(arg1:string):Promise<boolean>;
2224

2325
export function SetCalibrationPoints(arg1:Record<string, main.CalibrationPoint>):Promise<void>;

frontend/wailsjs/go/main/App.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ export function Log(arg1) {
3434
return window['go']['main']['App']['Log'](arg1);
3535
}
3636

37+
export function OpenLogFile() {
38+
return window['go']['main']['App']['OpenLogFile']();
39+
}
40+
3741
export function SaveFile(arg1) {
3842
return window['go']['main']['App']['SaveFile'](arg1);
3943
}

0 commit comments

Comments
 (0)