fix numeric notation of permissions
This commit is contained in:
parent
d01f2dddcc
commit
8b57b22c20
@ -67,6 +67,8 @@ type fileLogWriter struct {
|
|||||||
|
|
||||||
Perm string `json:"perm"`
|
Perm string `json:"perm"`
|
||||||
|
|
||||||
|
DirPerm string `json:"dirperm"`
|
||||||
|
|
||||||
RotatePerm string `json:"rotateperm"`
|
RotatePerm string `json:"rotateperm"`
|
||||||
|
|
||||||
fileNameOnly, suffix string // like "project.log", project is fileNameOnly and .log is suffix
|
fileNameOnly, suffix string // like "project.log", project is fileNameOnly and .log is suffix
|
||||||
@ -86,6 +88,7 @@ func newFileWriter() Logger {
|
|||||||
RotatePerm: "0440",
|
RotatePerm: "0440",
|
||||||
Level: LevelTrace,
|
Level: LevelTrace,
|
||||||
Perm: "0660",
|
Perm: "0660",
|
||||||
|
DirPerm: "0770",
|
||||||
MaxLines: 10000000,
|
MaxLines: 10000000,
|
||||||
MaxFiles: 999,
|
MaxFiles: 999,
|
||||||
MaxSize: 1 << 28,
|
MaxSize: 1 << 28,
|
||||||
@ -217,8 +220,13 @@ func (w *fileLogWriter) createLogFile() (*os.File, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dirperm, err := strconv.ParseInt(w.DirPerm, 8, 64)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
filepath := path.Dir(w.Filename)
|
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))
|
fd, err := os.OpenFile(w.Filename, os.O_WRONLY|os.O_APPEND|os.O_CREATE, os.FileMode(perm))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user