code: func decodeFunc(rdr io.Reader) func() (*logger.Message, error) {
  	l := &jsonlog.JSONLog{}
  	dec := json.NewDecoder(rdr)
  	return func() (msg *logger.Message, err error) {
  		for retries := 0; retries < maxJSONDecodeRetry; retries++ {
  			msg, err = decodeLogLine(dec, l)
  			if err == nil || err == io.EOF {
  				break
  			}
  
  			logrus.WithError(err).WithField("retries", retries).Warn("got error while decoding json")
  			// try again, could be due to a an incomplete json object as we read
  			if _, ok := err.(*json.SyntaxError); ok {
  				dec = json.NewDecoder(rdr)
  				continue
  			}
  
  			// io.ErrUnexpectedEOF is returned from json.Decoder when there is
  			// remaining data in the parser's buffer while an io.EOF occurs.
  			// If the json logger writes a partial json log entry to the disk
  			// while at the same time the decoder tries to decode it, the race condition happens.
  			if err == io.ErrUnexpectedEOF {
  				reader := io.MultiReader(dec.Buffered(), rdr)
  				dec = json.NewDecoder(reader)
  				continue
  			}
  		}
  		return msg, err
  	}
  }
docs: // decodeFunc is used to create a decoder for the log file reader