feat: log files to user directory
This commit is contained in:
parent
e4ce9b6552
commit
25229f1ea8
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue