mirror of
https://github.com/astaxie/beego.git
synced 2024-11-26 06:11:29 +00:00
Merge pull request #2556 from zjjott/master
fix: log mode should be 0440 should not be 440
This commit is contained in:
commit
405c170d45
@ -268,7 +268,7 @@ func (w *fileLogWriter) doRotate(logTime time.Time) error {
|
|||||||
// Rename the file to its new found name
|
// Rename the file to its new found name
|
||||||
// even if occurs error,we MUST guarantee to restart new logger
|
// even if occurs error,we MUST guarantee to restart new logger
|
||||||
err = os.Rename(w.Filename, fName)
|
err = os.Rename(w.Filename, fName)
|
||||||
err = os.Chmod(fName, os.FileMode(440))
|
err = os.Chmod(fName, os.FileMode(0440))
|
||||||
// re-start logger
|
// re-start logger
|
||||||
RESTART_LOGGER:
|
RESTART_LOGGER:
|
||||||
|
|
||||||
|
@ -162,7 +162,27 @@ func TestFileRotate_05(t *testing.T) {
|
|||||||
testFileDailyRotate(t, fn1, fn2)
|
testFileDailyRotate(t, fn1, fn2)
|
||||||
os.Remove(fn)
|
os.Remove(fn)
|
||||||
}
|
}
|
||||||
|
func TestFileRotate_06(t *testing.T) {//test file mode
|
||||||
|
log := NewLogger(10000)
|
||||||
|
log.SetLogger("file", `{"filename":"test3.log","maxlines":4}`)
|
||||||
|
log.Debug("debug")
|
||||||
|
log.Info("info")
|
||||||
|
log.Notice("notice")
|
||||||
|
log.Warning("warning")
|
||||||
|
log.Error("error")
|
||||||
|
log.Alert("alert")
|
||||||
|
log.Critical("critical")
|
||||||
|
log.Emergency("emergency")
|
||||||
|
rotateName := "test3" + fmt.Sprintf(".%s.%03d", time.Now().Format("2006-01-02"), 1) + ".log"
|
||||||
|
s,_:=os.Lstat(rotateName)
|
||||||
|
if s.Mode() != 0440 {
|
||||||
|
os.Remove(rotateName)
|
||||||
|
os.Remove("test3.log")
|
||||||
|
t.Fatal("rotate file mode error")
|
||||||
|
}
|
||||||
|
os.Remove(rotateName)
|
||||||
|
os.Remove("test3.log")
|
||||||
|
}
|
||||||
func testFileRotate(t *testing.T, fn1, fn2 string) {
|
func testFileRotate(t *testing.T, fn1, fn2 string) {
|
||||||
fw := &fileLogWriter{
|
fw := &fileLogWriter{
|
||||||
Daily: true,
|
Daily: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user