code: func RotatingFileHandler(path string, limit uint, formatter Format) (Handler, error) {
  	if err := os.MkdirAll(path, 0700); err != nil {
  		return nil, err
  	}
  	files, err := ioutil.ReadDir(path)
  	if err != nil {
  		return nil, err
  	}
  	re := regexp.MustCompile(`\.log$`)
  	last := len(files) - 1
  	for last >= 0 && (!files[last].Mode().IsRegular() || !re.MatchString(files[last].Name())) {
  		last--
  	}
  	var counter *countingWriter
  	if last >= 0 && files[last].Size() < int64(limit) {
  		// Open the last file, and continue to write into it until it's size reaches the limit.
  		if counter, err = prepFile(filepath.Join(path, files[last].Name())); err != nil {
  			return nil, err
  		}
  	}
  	if counter == nil {
  		counter = new(countingWriter)
  	}
  	h := StreamHandler(counter, formatter)
  
  	return FuncHandler(func(r *Record) error {
  		if counter.count > limit {
  			counter.Close()
  			counter.w = nil
  		}
  		if counter.w == nil {
  			f, err := os.OpenFile(
  				filepath.Join(path, fmt.Sprintf("%s.log", strings.Replace(r.Time.Format("060102150405.00"), ".", "", 1))),
  				os.O_CREATE|os.O_APPEND|os.O_WRONLY,
  				0600,
  			)
  			if err != nil {
  				return err
  			}
  			counter.w = f
  			counter.count = 0
  		}
  		return h.Log(r)
  	}), nil
  }
docs: // RotatingFileHandler returns a handler which writes log records to file chunks
  // at the given path. When a file's size reaches the limit, the handler creates
  // a new file named after the timestamp of the first log record it will contain.