diff --git a/logs/file.go b/logs/file.go index 1c2db882..0b827857 100644 --- a/logs/file.go +++ b/logs/file.go @@ -56,17 +56,20 @@ type fileLogWriter struct { Perm string `json:"perm"` + OtherPerm string `json:"otherperm"` + fileNameOnly, suffix string // like "project.log", project is fileNameOnly and .log is suffix } // newFileWriter create a FileLogWriter returning as LoggerInterface. func newFileWriter() Logger { w := &fileLogWriter{ - Daily: true, - MaxDays: 7, - Rotate: true, - Level: LevelTrace, - Perm: "0660", + Daily: true, + MaxDays: 7, + Rotate: true, + OtherPerm: "0440", + Level: LevelTrace, + Perm: "0660", } return w } @@ -237,8 +240,12 @@ func (w *fileLogWriter) doRotate(logTime time.Time) error { // Find the next available number num := 1 fName := "" + otherPerm, err := strconv.ParseInt(w.OtherPerm, 8, 64) + if err != nil { + return err + } - _, err := os.Lstat(w.Filename) + _, err = os.Lstat(w.Filename) if err != nil { //even if the file is not exist or other ,we should RESTART the logger goto RESTART_LOGGER @@ -271,7 +278,9 @@ func (w *fileLogWriter) doRotate(logTime time.Time) error { if err != nil { goto RESTART_LOGGER } - err = os.Chmod(fName, os.FileMode(0440)) + //err = os.Chmod(fName, os.FileMode(0444)) + + err = os.Chmod(fName, os.FileMode(otherPerm)) // re-start logger RESTART_LOGGER: