fileLogger.go
func (f *FileLogger) split() {

	logFile := joinFilePath(f.fileDir, f.fileName)

	switch f.splitType {
	case SplitType_Size:
		f.suffix = int(f.suffix%f.fileCount + 1)
		if f.logFile != nil {
			f.logFile.Close()
		}

		logFileBak := logFile + "." + strconv.Itoa(f.suffix)
		if isExist(logFileBak) {
			os.Remove(logFileBak)
		}
		os.Rename(logFile, logFileBak)

		f.logFile, _ = os.Create(logFile)
		f.lg = log.New(f.logFile, f.prefix, log.LstdFlags|log.Lmicroseconds)

	case SplitType_Daily:
		logFileBak := logFile + "." + f.date.Format(DATEFORMAT)
		if !isExist(logFileBak) && f.isMustSplit() {
			if f.logFile != nil {
				f.logFile.Close()
			}

			err := os.Rename(logFile, logFileBak)
			if err != nil {
				f.lg.Printf("FileLogger rename error: %v", err.Error())
			}

			t, _ := time.Parse(DATEFORMAT, time.Now().Format(DATEFORMAT))
			f.date = &t
			f.logFile, _ = os.Create(logFile)
			f.lg = log.New(f.logFile, f.prefix, log.LstdFlags|log.Lmicroseconds)
		}
	}
}
func (f *FileLogger) split() {

	logFile := joinFilePath(f.fileDir, f.fileName)

	switch f.splitType {
	case SplitType_Size:
		f.suffix = int(f.suffix%f.fileCount + 1)
		if f.logFile != nil {
			f.logFile.Close()
		}

		logFileBak := logFile + "." + strconv.Itoa(f.suffix)
		if isExist(logFileBak) {
			os.Remove(logFileBak)
		}
		os.Rename(logFile, logFileBak)

		f.logFile, _ = os.Create(logFile)
		f.lg = log.New(f.logFile, f.prefix, log.LstdFlags|log.Lmicroseconds)

	case SplitType_Daily:
		logFileBak := logFile + "." + f.date.Format(DATEFORMAT)
		if !isExist(logFileBak) && f.isMustSplit() {
			if f.logFile != nil {
				f.logFile.Close()
			}

			err := os.Rename(logFile, logFileBak)
			if err != nil {
				f.lg.Printf("FileLogger rename error: %v", err.Error())
			}

			t, _ := time.Parse(DATEFORMAT, time.Now().Format(DATEFORMAT))
			f.date = &t
			f.logFile, _ = os.Create(logFile)
			f.lg = log.New(f.logFile, f.prefix, log.LstdFlags|log.Lmicroseconds)
		}
	}
}
func ( f * FileLogger ) split ( ) { logFile := joinFilePath ( f . fileDir , f . fileName ) switch f . splitType { case SplitType_Size : f . suffix = int ( f . suffix % f . fileCount + 1 ) if f . logFile != nil { f . logFile . Close ( ) } logFileBak := logFile + " " + strconv . Itoa ( f . suffix ) if isExist ( logFileBak ) { os . Remove ( logFileBak ) } os . Rename ( logFile , logFileBak ) f . logFile , _ = os . Create ( logFile ) f . lg = log . New ( f . logFile , f . prefix , log . LstdFlags | log . Lmicroseconds ) case SplitType_Daily : logFileBak := logFile + " " + f . date . Format ( DATEFORMAT ) if ! isExist ( logFileBak ) && f . isMustSplit ( ) { if f . logFile != nil { f . logFile . Close ( ) } err := os . Rename ( logFile , logFileBak ) if err != nil { f . lg . Printf ( " " , err . Error ( ) ) } t , _ := time . Parse ( DATEFORMAT , time . Now ( ) . Format ( DATEFORMAT ) ) f . date = & t f . logFile , _ = os . Create ( logFile ) f . lg = log . New ( f . logFile , f . prefix , log . LstdFlags | log . Lmicroseconds ) } } }
// Split fileLogger
Split fileLogger