1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 15:00:54 +00:00

fix all confict

This commit is contained in:
two 2018-07-26 14:34:25 +08:00
parent 38a2f32252
commit 31c746d9d7
2 changed files with 6 additions and 40 deletions

View File

@ -306,7 +306,6 @@ func (w *fileLogWriter) doRotate(logTime time.Time) error {
goto RESTART_LOGGER goto RESTART_LOGGER
} }
<<<<<<< HEAD
if w.Hourly { if w.Hourly {
format = "2006010215" format = "2006010215"
openTime = w.hourlyOpenTime openTime = w.hourlyOpenTime
@ -315,31 +314,18 @@ func (w *fileLogWriter) doRotate(logTime time.Time) error {
openTime = w.dailyOpenTime openTime = w.dailyOpenTime
} }
// only when one of them be setted, then the file would be splited
if w.MaxLines > 0 || w.MaxSize > 0 { if w.MaxLines > 0 || w.MaxSize > 0 {
for ; err == nil && num <= 999; num++ { for ; err == nil && num <= w.MaxFiles; num++ {
fName = w.fileNameOnly + fmt.Sprintf(".%s.%03d%s", logTime.Format(format), num, w.suffix) fName = w.fileNameOnly + fmt.Sprintf(".%s.%03d%s", logTime.Format(format), num, w.suffix)
_, err = os.Lstat(fName) _, err = os.Lstat(fName)
} }
} else { } else {
fName = fmt.Sprintf("%s.%s%s", w.fileNameOnly, openTime.Format(format), w.suffix)
_, err = os.Lstat(fName)
for ; err == nil && num <= 999; num++ {
fName = w.fileNameOnly + fmt.Sprintf(".%s.%03d%s", openTime.Format(format), num, w.suffix) fName = w.fileNameOnly + fmt.Sprintf(".%s.%03d%s", openTime.Format(format), num, w.suffix)
_, err = os.Lstat(fName) _, err = os.Lstat(fName)
}
=======
// only when one of them be setted, then the file would be splited
if w.MaxLines > 0 || w.MaxSize > 0 {
for ; err == nil && num <= w.MaxFiles; num++ {
fName = w.fileNameOnly + fmt.Sprintf(".%s.%03d%s", logTime.Format("2006-01-02"), num, w.suffix)
_, err = os.Lstat(fName)
}
} else {
fName = w.fileNameOnly + fmt.Sprintf(".%s.%03d%s", w.dailyOpenTime.Format("2006-01-02"), num, w.suffix)
_, err = os.Lstat(fName)
w.MaxFilesCurFiles = num w.MaxFilesCurFiles = num
>>>>>>> old/develop
} }
// return error if the last file checked still existed // return error if the last file checked still existed
if err == nil { if err == nil {
return fmt.Errorf("Rotate: Cannot find free log number to rename %s", w.Filename) return fmt.Errorf("Rotate: Cannot find free log number to rename %s", w.Filename)
@ -383,7 +369,6 @@ func (w *fileLogWriter) deleteOldLog() {
if info == nil { if info == nil {
return return
} }
<<<<<<< HEAD
if w.Hourly { if w.Hourly {
if !info.IsDir() && info.ModTime().Add(1 * time.Hour * time.Duration(w.MaxHours)).Before(time.Now()) { if !info.IsDir() && info.ModTime().Add(1 * time.Hour * time.Duration(w.MaxHours)).Before(time.Now()) {
if strings.HasPrefix(filepath.Base(path), filepath.Base(w.fileNameOnly)) && if strings.HasPrefix(filepath.Base(path), filepath.Base(w.fileNameOnly)) &&
@ -399,15 +384,6 @@ func (w *fileLogWriter) deleteOldLog() {
} }
} }
} }
=======
if !info.IsDir() && info.ModTime().Add(24 * time.Hour * time.Duration(w.MaxDays)).Before(time.Now()) {
if strings.HasPrefix(filepath.Base(path), filepath.Base(w.fileNameOnly)) &&
strings.HasSuffix(filepath.Base(path), w.suffix) {
os.Remove(path)
}
}
>>>>>>> old/develop
return return
}) })
} }

View File

@ -30,13 +30,8 @@ func TestFormatHeader_0(t *testing.T) {
if tm.Year() >= 2100 { if tm.Year() >= 2100 {
break break
} }
<<<<<<< HEAD
h, _, _ := formatTimeHeader(tm) h, _, _ := formatTimeHeader(tm)
if tm.Format("2006/01/02 15:04:05.999 ") != string(h) {
=======
h, _ := formatTimeHeader(tm)
if tm.Format("2006/01/02 15:04:05.000 ") != string(h) { if tm.Format("2006/01/02 15:04:05.000 ") != string(h) {
>>>>>>> old/develop
t.Log(tm) t.Log(tm)
t.FailNow() t.FailNow()
} }
@ -53,13 +48,8 @@ func TestFormatHeader_1(t *testing.T) {
if tm.Year() >= year+1 { if tm.Year() >= year+1 {
break break
} }
<<<<<<< HEAD
h, _, _ := formatTimeHeader(tm) h, _, _ := formatTimeHeader(tm)
if tm.Format("2006/01/02 15:04:05.999 ") != string(h) {
=======
h, _ := formatTimeHeader(tm)
if tm.Format("2006/01/02 15:04:05.000 ") != string(h) { if tm.Format("2006/01/02 15:04:05.000 ") != string(h) {
>>>>>>> old/develop
t.Log(tm) t.Log(tm)
t.FailNow() t.FailNow()
} }