Client logs are now stored in the cache dir

This commit is contained in:
2025-07-30 20:46:50 +03:00
parent e4e7038247
commit 7c48c09ec3
4 changed files with 17 additions and 21 deletions

View File

@@ -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()
}

View File

@@ -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

View File

@@ -34,8 +34,6 @@ import (
)
const (
DEBUG = true
MinWidth = 85
MinHeight = 25
Center lipgloss.Position = 0.499

View File

@@ -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"