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 /internal/client | |
| parent | e4e70382471ded52af4da1872d8544da0428d3a4 (diff) | |
Client logs are now stored in the cache dir
Diffstat (limited to 'internal/client')
| -rw-r--r-- | internal/client/client.go | 24 | ||||
| -rw-r--r-- | internal/client/ui/ui.go | 2 |
2 files changed, 15 insertions, 11 deletions
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 |
