Compare commits

..

2 Commits

Author SHA1 Message Date
25229f1ea8
feat: log files to user directory
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build is failing
2023-12-29 19:04:45 +01:00
e4ce9b6552
feat: version handling 2023-12-29 18:54:41 +01:00
3 changed files with 24 additions and 16 deletions

View File

@ -7,6 +7,7 @@ import (
"os"
"os/exec"
"os/user"
"path"
"d1.hackers.moe/cairde/ui"
@ -75,28 +76,37 @@ func main() {
os.Exit(0)
}
// NOTE(d1): pending https://git.coopcloud.tech/decentral1se/cairde/issues/1
_, err := exec.LookPath("tor")
// NOTE(d1): pending https://git.coopcloud.tech/decentral1se/cairde/issues/1
if err != nil {
log.Fatal("main: could not find 'tor' command, is it installed?")
}
f, err := tea.LogToFile("cairde.log", "debug") // TODO
if err != nil {
log.Fatal(err)
}
defer f.Close()
filelogger, err := openPrivacyLog.NewFile(openPrivacyLog.LevelInfo, "cwtch.log") // TODO
if err == nil {
openPrivacyLog.SetStd(filelogger)
}
user, err := user.Current()
if err != nil {
log.Fatalf("main: unable to determine current user: %s", err)
}
userDir := path.Join(user.HomeDir, "/.cairde/")
if err := os.Mkdir(userDir, 0764); err != nil {
if !os.IsExist(err) {
log.Fatalf("main: unable to create user directory: %s", err)
}
}
cairdeLogPath := path.Join(userDir, "cairde.log")
f, err := tea.LogToFile(cairdeLogPath, "debug")
if err != nil {
log.Fatal(err)
}
defer f.Close()
cwtchLogPath := path.Join(userDir, "cwtch.log")
filelogger, err := openPrivacyLog.NewFile(openPrivacyLog.LevelInfo, cwtchLogPath)
if err == nil {
openPrivacyLog.SetStd(filelogger)
}
p := tea.NewProgram(
ui.NewModel(
user.Username,

View File

@ -340,6 +340,3 @@ func TestAcnOffIsOff(t *testing.T) {
testModel.WaitFinished(t, teatest.WithFinalTimeout(time.Second))
}
func TestVersionOutput(t *testing.T) {
}

View File

@ -17,7 +17,8 @@ ci:
@golangci-lint run ./...
clean:
@find -type f -name "*.log" -exec rm '{}' \;
@go clean && \
find ~/.cairde -type f -name "*.log" -exec rm '{}' \;
build: clean
@go build -ldflags=$(DIST_LDFLAGS) ./cmd/cairde