code: func waitLogs(ctx context.Context, id string, w *fsnotify.Watcher, runtimeService internalapi.RuntimeService) (bool, bool, error) {
  	// no need to wait if the pod is not running
  	if running, err := isContainerRunning(id, runtimeService); !running {
  		return false, false, err
  	}
  	errRetry := 5
  	for {
  		select {
  		case <-ctx.Done():
  			return false, false, fmt.Errorf("context cancelled")
  		case e := <-w.Events:
  			switch e.Op {
  			case fsnotify.Write:
  				return true, false, nil
  			case fsnotify.Create:
  				fallthrough
  			case fsnotify.Rename:
  				fallthrough
  			case fsnotify.Remove:
  				fallthrough
  			case fsnotify.Chmod:
  				return true, true, nil
  			default:
  				klog.Errorf("Unexpected fsnotify event: %v, retrying...", e)
  			}
  		case err := <-w.Errors:
  			klog.Errorf("Fsnotify watch error: %v, %d error retries remaining", err, errRetry)
  			if errRetry == 0 {
  				return false, false, err
  			}
  			errRetry--
  		case <-time.After(logForceCheckPeriod):
  			return true, false, nil
  		case <-time.After(stateCheckPeriod):
  			if running, err := isContainerRunning(id, runtimeService); !running {
  				return false, false, err
  			}
  		}
  	}
  }
docs: // waitLogs wait for the next log write. It returns two booleans and an error. The first boolean
  // indicates whether a new log is found; the second boolean if the log file was recreated;
  // the error is error happens during waiting new logs.