diff options
| author | Kyren223 <kyren223@proton.me> | 2025-07-30 20:46:50 +0300 |
|---|---|---|
| committer | Kyren223 <kyren223@proton.me> | 2025-07-30 20:46:50 +0300 |
| commit | 7c48c09ec3e7c2f5b4bc1eadf0ee0553b79a6581 (patch) | |
| tree | e36966aaed0126c404fa365a140c45707855615e | |
| parent | e4e70382471ded52af4da1872d8544da0428d3a4 (diff) | |
Client logs are now stored in the cache dir
| -rw-r--r-- | cmd/client/main.go | 8 | ||||
| -rw-r--r-- | internal/client/client.go | 24 | ||||
| -rw-r--r-- | internal/client/ui/ui.go | 2 | ||||
| -rw-r--r-- | mprocs.yaml | 4 |
4 files changed, 17 insertions, 21 deletions
diff --git a/cmd/client/main.go b/cmd/client/main.go index 00baefb..42ce05d 100644 --- a/cmd/client/main.go +++ b/cmd/client/main.go @@ -18,7 +18,6 @@ package main import ( "fmt" - "log" "os" "strconv" "time" @@ -42,12 +41,5 @@ func main() { return } - logFile, err := os.OpenFile("client.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0600) - if err != nil { - log.Fatalln(err) - } - defer logFile.Close() - log.SetOutput(logFile) - client.Run() } diff --git a/internal/client/client.go b/internal/client/client.go index d3cec0b..f38b649 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -21,6 +21,7 @@ import ( "io" "log" "os" + "path" "reflect" "strconv" "strings" @@ -46,15 +47,6 @@ func (c BubbleTeaCloser) Close() error { } func Run() { - var dump *os.File - if ui.DEBUG { - var err error - dump, err = os.OpenFile("messages.log", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0o600) - if err != nil { - os.Exit(1) - } - } - log.Println("client started") err := config.LoadConfig() @@ -68,6 +60,20 @@ func Run() { os.Exit(1) } + logPath := path.Join(config.CacheDir, "client.log") + logFile, err := os.OpenFile(logPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0600) // #nosec G304 + if err != nil { + log.Fatalln(err) + } + defer logFile.Close() + log.SetOutput(logFile) + + dumpPath := path.Join(config.CacheDir, "messages.log") + dump, err := os.OpenFile(dumpPath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0o600) // #nosec G304 + if err != nil { + os.Exit(1) + } + program := tea.NewProgram(initialModel(dump), tea.WithAltScreen()) assert.AddFlush(BubbleTeaCloser{program}) ui.Program = program diff --git a/internal/client/ui/ui.go b/internal/client/ui/ui.go index 819508d..369bbff 100644 --- a/internal/client/ui/ui.go +++ b/internal/client/ui/ui.go @@ -34,8 +34,6 @@ import ( ) const ( - DEBUG = true - MinWidth = 85 MinHeight = 25 Center lipgloss.Position = 0.499 diff --git a/mprocs.yaml b/mprocs.yaml index 4efa0f9..32929a9 100644 --- a/mprocs.yaml +++ b/mprocs.yaml @@ -6,8 +6,8 @@ procs: client-secondary: shell: "go run ./cmd/client" client-log: - shell: "tail -f client.log" + shell: "tail -f $HOME/.cache/eko/client.log" messages-log: - shell: "tail -f messages.log" + shell: "tail -f $HOME/.cache/eko/messages.log" check-ci: shell: "./tools/check-ci.sh" |
