Skip to content

Commit

Permalink
server: Fix log path initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ish-hcc committed Sep 29, 2024
1 parent 6ecd02c commit f01eb77
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
15 changes: 15 additions & 0 deletions server/cmd/cm-honeybee/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ func init() {
log.Fatalln(err)
}

common.RootPath = os.Getenv(common.ModuleROOT)
if len(common.RootPath) == 0 {
homeDir, err := os.UserHomeDir()
if err != nil {
log.Fatalln(err)
}

common.RootPath = homeDir + "/." + strings.ToLower(common.ModuleName)
}

err = fileutil.CreateDirIfNotExist(common.RootPath)
if err != nil {
log.Fatalln(err)
}

err = logger.InitLogFile(common.RootPath+"/log", strings.ToLower(common.ModuleName))
if err != nil {
log.Panicln(err)
Expand Down
15 changes: 0 additions & 15 deletions server/lib/config/cm-honeybee.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,6 @@ func getCMHoneybeeDefaultConfig() cmHoneybeeConfig {
}

func readCMHoneybeeConfigFile() error {
common.RootPath = os.Getenv(common.ModuleROOT)
if len(common.RootPath) == 0 {
homeDir, err := os.UserHomeDir()
if err != nil {
return err
}

common.RootPath = homeDir + "/." + strings.ToLower(common.ModuleName)
}

err := fileutil.CreateDirIfNotExist(common.RootPath)
if err != nil {
return err
}

ex, err := os.Executable()
if err != nil {
return err
Expand Down

0 comments on commit f01eb77

Please sign in to comment.