refactor: use ~/.cairde/logs dir for logs
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
22e083e58b
commit
ee80ef2c67
|
@ -1,3 +1,4 @@
|
|||
// main is the command-line entrypoint.
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -87,21 +88,24 @@ func main() {
|
|||
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)
|
||||
cairdeHomeDir := path.Join(user.HomeDir, ".cairde")
|
||||
cairdeLogsDir := path.Join(cairdeHomeDir, "logs")
|
||||
for _, baseDir := range []string{cairdeHomeDir, cairdeLogsDir} {
|
||||
if err := os.Mkdir(baseDir, 0764); err != nil {
|
||||
if !os.IsExist(err) {
|
||||
log.Fatalf("main: unable to create directory %s: %s", baseDir, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cairdeLogPath := path.Join(userDir, "cairde.log")
|
||||
cairdeLogPath := path.Join(cairdeLogsDir, "cairde.log")
|
||||
f, err := tea.LogToFile(cairdeLogPath, "debug")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
cwtchLogPath := path.Join(userDir, "cwtch.log")
|
||||
cwtchLogPath := path.Join(cairdeLogsDir, "cwtch.log")
|
||||
filelogger, err := openPrivacyLog.NewFile(openPrivacyLog.LevelInfo, cwtchLogPath)
|
||||
if err == nil {
|
||||
openPrivacyLog.SetStd(filelogger)
|
||||
|
|
Loading…
Reference in New Issue