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

	f.mu.Lock()
	defer f.mu.Unlock()

	logFile := joinFilePath(f.fileDir, f.fileName)
	for i := 1; i <= f.fileCount; i++ {
		if !isExist(logFile + "." + strconv.Itoa(i)) {
			break
		}

		f.suffix = i
	}

	if !f.isMustSplit() {
		if !isExist(f.fileDir) {
			os.Mkdir(f.fileDir, 0755)
		}
		f.logFile, _ = os.OpenFile(logFile, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0666)
		f.lg = log.New(f.logFile, f.prefix, log.LstdFlags|log.Lmicroseconds)
	} else {
		f.split()
	}

	go f.logWriter()
	go f.fileMonitor()
}
func (f *FileLogger) initLoggerBySize() {

	f.mu.Lock()
	defer f.mu.Unlock()

	logFile := joinFilePath(f.fileDir, f.fileName)
	for i := 1; i <= f.fileCount; i++ {
		if !isExist(logFile + "." + strconv.Itoa(i)) {
			break
		}

		f.suffix = i
	}

	if !f.isMustSplit() {
		if !isExist(f.fileDir) {
			os.Mkdir(f.fileDir, 0755)
		}
		f.logFile, _ = os.OpenFile(logFile, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0666)
		f.lg = log.New(f.logFile, f.prefix, log.LstdFlags|log.Lmicroseconds)
	} else {
		f.split()
	}

	go f.logWriter()
	go f.fileMonitor()
}
func ( f * FileLogger ) initLoggerBySize ( ) { f . mu . Lock ( ) defer f . mu . Unlock ( ) logFile := joinFilePath ( f . fileDir , f . fileName ) for i := 1 ; i <= f . fileCount ; i ++ { if ! isExist ( logFile + " " + strconv . Itoa ( i ) ) { break } f . suffix = i } if ! f . isMustSplit ( ) { if ! isExist ( f . fileDir ) { os . Mkdir ( f . fileDir , 0755 ) } f . logFile , _ = os . OpenFile ( logFile , os . O_RDWR | os . O_APPEND | os . O_CREATE , 0666 ) f . lg = log . New ( f . logFile , f . prefix , log . LstdFlags | log . Lmicroseconds ) } else { f . split ( ) } go f . logWriter ( ) go f . fileMonitor ( ) }
// init filelogger split by fileSize
init filelogger split by fileSize