code: private function logScriptOutput()
      {
          $output_buffers = array();
          $ob_cnt = 0;
          while (ob_get_level() > $this->output_buffer_level)
          {
              $output = trim(ob_get_contents());
              ++$ob_cnt;
              ob_end_clean();
              if (!empty($output))
              {
                  $lines = explode("\n", $output);
                  foreach ($lines as $n => $line)
                      self::$logger->debug("Script output: {0}/{1}: {2}", [$ob_cnt, $n + 1, $line]);
              }
          }
      }
docs: Log all output of the script to the logger.