From 7035a3fe9c1cc06d09d9559c5f6c3a29d8d895e2 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Tue, 25 May 2021 20:16:42 +0100 Subject: [PATCH] Tray: Add button to open logs --- go.mod | 1 + go.sum | 2 ++ main.go | 2 +- tray.go | 4 ++++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 3b6a5a3..33d4591 100644 --- a/go.mod +++ b/go.mod @@ -39,6 +39,7 @@ require ( github.com/mailgun/mailgun-go/v4 v4.5.1 github.com/mailru/easyjson v0.7.7 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect github.com/smartystreets/goconvey v1.6.4 // indirect github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14 github.com/swaggo/gin-swagger v1.3.0 diff --git a/go.sum b/go.sum index 803830b..42b3910 100644 --- a/go.sum +++ b/go.sum @@ -221,6 +221,8 @@ github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 h1:JIAuq3EEf9cgbU6AtGPK4CTG3Zf6CKMNqf0MHTggAUA= +github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= diff --git a/main.go b/main.go index e9a2e78..fa4749d 100644 --- a/main.go +++ b/main.go @@ -723,7 +723,7 @@ func logOutput() func() { old := os.Stdout log.Printf("Logging to \"%s\"", logPath) f, err := os.OpenFile(logPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666) - if err == nil { + if err != nil { return func() {} } writer := io.MultiWriter(old, f) diff --git a/tray.go b/tray.go index c48a6ba..e1b1f6e 100644 --- a/tray.go +++ b/tray.go @@ -9,6 +9,7 @@ import ( "syscall" "github.com/getlantern/systray" + "github.com/skratchdot/open-golang/open" // "github.com/getlantern/systray" ) @@ -36,6 +37,7 @@ func onReady() { mStart := systray.AddMenuItem("Start", "Start jfa-go") mStop := systray.AddMenuItem("Stop", "Stop jfa-go") mRestart := systray.AddMenuItem("Restart", "Restart jfa-go") + mOpenLogs := systray.AddMenuItem("Open logs", "Open jfa-go log file.") as := NewAutostart("jfa-go", "A user management system for Jellyfin", "Run on login", "Run jfa-go on user login.") mQuit := systray.AddMenuItem("Quit", "Quit jfa-go") @@ -88,6 +90,8 @@ func onReady() { mStop.Enable() mRestart.Enable() } + case <-mOpenLogs.ClickedCh: + open.Start(logPath) case <-mQuit.ClickedCh: systray.Quit() // case <-mOnLogin.ClickedCh: