code: private function clearErrorsHelper(&$log, $clear = true)
      {
          $errorsNotCleared = array();
          foreach ($log as $k => $entry) {
              if (!\in_array($entry[0], array('error','warn'))) {
                  continue;
              }
              $clear2 = $clear;
              if ($this->channelName) {
                  $channel = isset($entry[2]['channel']) ? $entry[2]['channel'] : null;
                  $clear2 = $clear && $channel === $this->channelName;
              }
              if ($clear2) {
                  unset($log[$k]);
              } elseif (isset($entry[2]['errorHash'])) {
                  $errorsNotCleared[] = $entry[2]['errorHash'];
              }
          }
          $log = \array_values($log);
          return $errorsNotCleared;
      }
docs: clear errors for given log
  
  @param array   $log   reference to log to clear of errors
  @param boolean $clear clear errors, or return errors?
  
  @return string[] array of error-hashes not cleared