diff --git a/core/logs/file.go b/core/logs/file.go index 80114db2..d90265b7 100644 --- a/core/logs/file.go +++ b/core/logs/file.go @@ -67,6 +67,8 @@ type fileLogWriter struct { Perm string `json:"perm"` + DirPerm string `json:"dirperm"` + RotatePerm string `json:"rotateperm"` fileNameOnly, suffix string // like "project.log", project is fileNameOnly and .log is suffix @@ -86,6 +88,7 @@ func newFileWriter() Logger { RotatePerm: "0440", Level: LevelTrace, Perm: "0660", + DirPerm: "0770", MaxLines: 10000000, MaxFiles: 999, MaxSize: 1 << 28, @@ -217,8 +220,13 @@ func (w *fileLogWriter) createLogFile() (*os.File, error) { return nil, err } + dirperm, err := strconv.ParseInt(w.DirPerm, 8, 64) + if err != nil { + return nil, err + } + filepath := path.Dir(w.Filename) - os.MkdirAll(filepath, os.FileMode(perm)) + os.MkdirAll(filepath, os.FileMode(dirperm)) fd, err := os.OpenFile(w.Filename, os.O_WRONLY|os.O_APPEND|os.O_CREATE, os.FileMode(perm)) if err == nil {