日志文件bug修复
This commit is contained in:
parent
410afb67fb
commit
e2fd36195d
|
|
@ -320,7 +320,19 @@ func startDaemonProcess() error {
|
|||
}
|
||||
goTimeFormat := formatGoTime(constants.LogNameFormate)
|
||||
logFileName := time.Now().Format(goTimeFormat)
|
||||
logFilePath := filepath.Join(constants.LogFilePath, logFileName)
|
||||
// logFilePath := filepath.Join(constants.LogFilePath, logFileName)
|
||||
var logFilePath string
|
||||
if isDebug() {
|
||||
logFilePath = filepath.Join(constants.LogFilePath, logFileName)
|
||||
} else {
|
||||
exePath, err := os.Executable()
|
||||
if err != nil {
|
||||
logger.Error("Error getting executable path: %v", err)
|
||||
return err
|
||||
}
|
||||
exeDir := filepath.Dir(exePath)
|
||||
logFilePath = filepath.Join(exeDir, constants.LogFilePath, logFileName)
|
||||
}
|
||||
logFile, err := os.OpenFile(logFilePath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, constants.LogFileMode)
|
||||
if err != nil {
|
||||
return fmt.Errorf("open log file: %w", err)
|
||||
|
|
|
|||
Loading…
Reference in New Issue