mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 20:00:54 +00:00
update error on type of w.Perm; change unit test perm value
This commit is contained in:
parent
cb3f240f44
commit
9572fdcf9a
@ -161,7 +161,7 @@ func (w *fileLogWriter) createLogFile() (*os.File, error) {
|
|||||||
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 {
|
||||||
// Make sure file perm is user set perm cause of `os.OpenFile` will obey umask
|
// Make sure file perm is user set perm cause of `os.OpenFile` will obey umask
|
||||||
os.Chmod(w.Filename, w.Perm)
|
os.Chmod(w.Filename, os.FileMode(perm))
|
||||||
}
|
}
|
||||||
return fd, err
|
return fd, err
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,8 @@ import (
|
|||||||
|
|
||||||
func TestFilePerm(t *testing.T) {
|
func TestFilePerm(t *testing.T) {
|
||||||
log := NewLogger(10000)
|
log := NewLogger(10000)
|
||||||
log.SetLogger("file", `{"filename":"test.log", "perm": "0600"}`)
|
// use 0666 as test perm cause the default umask is 022
|
||||||
|
log.SetLogger("file", `{"filename":"test.log", "perm": "0666"}`)
|
||||||
log.Debug("debug")
|
log.Debug("debug")
|
||||||
log.Informational("info")
|
log.Informational("info")
|
||||||
log.Notice("notice")
|
log.Notice("notice")
|
||||||
@ -39,7 +40,7 @@ func TestFilePerm(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if file.Mode() != 0600 {
|
if file.Mode() != 0666 {
|
||||||
t.Fatal("unexpected log file permission")
|
t.Fatal("unexpected log file permission")
|
||||||
}
|
}
|
||||||
os.Remove("test.log")
|
os.Remove("test.log")
|
||||||
|
Loading…
Reference in New Issue
Block a user