1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-22 22:10:48 +00:00

remove attribute perm to make it more brief

This commit is contained in:
nullne 2016-05-17 10:29:05 +08:00
parent d679a4b865
commit 2c12383263

View File

@ -55,7 +55,6 @@ type fileLogWriter struct {
Level int `json:"level"`
Perm string `json:"perm"`
perm os.FileMode
fileNameOnly, suffix string // like "project.log", project is fileNameOnly and .log is suffix
}
@ -68,7 +67,6 @@ func newFileWriter() Logger {
Rotate: true,
Level: LevelTrace,
Perm: "0660",
perm: 0660,
}
return w
}
@ -82,7 +80,7 @@ func newFileWriter() Logger {
// "daily":true,
// "maxDays":15,
// "rotate":true,
// "perm":0600
// "perm":"0600"
// }
func (w *fileLogWriter) Init(jsonConfig string) error {
err := json.Unmarshal([]byte(jsonConfig), w)
@ -92,11 +90,6 @@ func (w *fileLogWriter) Init(jsonConfig string) error {
if len(w.Filename) == 0 {
return errors.New("jsonconfig must have filename")
}
perm, err := strconv.ParseInt(w.Perm, 8, 64)
if err != nil {
return err
}
w.perm = os.FileMode(perm)
w.suffix = filepath.Ext(w.Filename)
w.fileNameOnly = strings.TrimSuffix(w.Filename, w.suffix)
if w.suffix == "" {
@ -161,7 +154,11 @@ func (w *fileLogWriter) WriteMsg(when time.Time, msg string, level int) error {
func (w *fileLogWriter) createLogFile() (*os.File, error) {
// Open the log file
fd, err := os.OpenFile(w.Filename, os.O_WRONLY|os.O_APPEND|os.O_CREATE, w.perm)
perm, err := strconv.ParseInt(w.Perm, 8, 64)
if err != nil {
return nil, err
}
fd, err := os.OpenFile(w.Filename, os.O_WRONLY|os.O_APPEND|os.O_CREATE, os.FileMode(perm))
return fd, err
}