Auto write Output to Browser or Console
@param $output
@param $handlerContentType
@author : evalor <master@evalor.cn>
502962
private function writeToOutputNow($output, $handlerContentType)
    {
        /** @var Response $Response */
        $Response = $this->system->ResIns();
        // If can do browser output
        if ($Response instanceof Response) {
            if ($this->sendHttpCode()) {
                $Response->withStatus($this->sendHttpCode());
            }
            $Response->withHeader('Content-Type', $handlerContentType);
            $Response->write($output);
            $Response->response();
            $Response->end(true);
        } else {
            Logger::getInstance()->console($output);
        }
    }
1170925
public void output(String output)
        throws XMLStreamException
    {
        if (mIsFlattening > 0) {
            try {
                mWriter.write(output);
            } catch (IOException ioe) {
                throw new WstxIOException(ioe);
            }
        }
    }
226728
function outputStdout(s, outputHandler) {
  if (outputHandler) {
    outputHandler(s);
  } else {
    process.stdout.write(s);
  }
}
321991
protected function setOutput(OutputInterface $output)
    {
        switch (Config::get('lumos.terminal')) {
            case 'bash':
                $op = new bashOutput($output);
                break;
            case 'cmd':
                $op = new cmdOutput($output);
                break;
            default:
                $op = new bashOutput($output);
                break;
        }
        //
        $this->console = $op;
        $this->output = $op->output;
    }
456654
protected function _execute($type, $data)
    {
        if (!isset($this->_handles[$type]))
        {
            $this->_tmp_handles = array();
            $path = \Swoole::$app_path.'/events/'.$type.'.php';
            if (is_file($path))
            {
                $_conf = include $path;
                if ($_conf and isset($_conf['handlers']) and is_array($_conf['handlers']))
                {
                    foreach ($_conf['handlers'] as $h)
                    {
                        if (class_exists($h))
                        {
                            $object = new $h;
                            if ($object instanceof IFace\EventHandler)
                            {
                                $this->_tmp_handles[] = $object;
                                continue;
                            }
                        }
                        trigger_error("invalid event handler[$type|$h]", E_USER_WARNING);
                    }
                }
            }
            $this->_handles[$type] = $this->_tmp_handles;
        }

        foreach($this->_handles[$type] as $handler)
        {
            /**
             * @var  $handler  IFace\EventHandler
             */
            $handler->trigger($type, $data);
        }
        return true;
    }
829968
static function exec( $method, &$result )
    {
        $ini = eZINI::instance( 'ezmultiupload.ini' );
        $handlers = $ini->variable( 'MultiUploadSettings', 'MultiuploadHandlers' );

        if ( !$handlers )
            return false;

        foreach ( $handlers as $hanlder )
        {
            if ( !call_user_func( array( $hanlder, $method ), $result ) )
                eZDebug::writeWarning( 'Multiupload handler implementation not found' );
        }

        return true;
    }
998329
function output($o)
	{

		if (is_array($o)) {
			$this->response->setContent(json_encode($o));
			$this->response->headers->set('Content-Type', 'application/json');
			die();

		} else {
			$this->response->setContent($o);
		}
	}
835907
def on_content_type(handlers, default=None, error='The requested content type does not match any of those allowed'):
    
    def output_type(data, request, response):
        handler = handlers.get(request.content_type.split(';')[0], default)
        if not handler:
            raise falcon.HTTPNotAcceptable(error)

        response.content_type = handler.content_type
        return handler(data, request=request, response=response)
    output_type.__doc__ = 'Supports any of the following formats: {0}'.format(', '.join(
        function.__doc__ or function.__name__ for function in handlers.values()))
    output_type.content_type = ', '.join(handlers.keys())
    return output_type
498965
protected function renderForConsole($e, ConsoleOutput $output = null)
    {
        if (is_null($output)) {
            $output = new ConsoleOutput();
        }

        $this->getExceptionHandler()->renderForConsole($output, $e);
    }
712448
public function setContentType(string $contentType): SetContentTypeHandlerInterface
    {
        $this->contentType = $this->normalizeContentType($contentType);
        return $this;
    }
207044
static function set_error_display( $handler ){
		if( ! is_callable($handler) ){
			trigger_error( 'Error display handler is not callable ('.var_export($handler,1).')', E_USER_WARNING );
			return false;
		}
		PLUGError::$displayfunc = $handler;
		return true;
	}
1049964
public function setOutput($output)
    {
        $psrLogBase = self::PSR_LOG_BASE;
        $consoleBase = self::SYMFONY_CONSOLE_BASE;

        if (($output instanceof $psrLogBase) === false && ($output instanceof $consoleBase) === false) {
            $className = get_class($output);
            $message = 'Output class "%s" not supported. Only "%s" or "%s"';
            throw new \Exception(sprintf($message, $className, $psrLogBase, $consoleBase), 1369595109);
        }

        $this->output = $output;
    }
389375
private function log_result($handle, $result) {

        if (!empty(self::$LOG)) {
            foreach (self::$LOG as $l) {

                if (!is_scalar($l)) {
                    $l = explode("\n", trim(print_r($l, true)));
                } elseif (strlen($l) > 256) {
                    $l = substr($l, 0, 256)."...(truncated)";
                }

                if (is_array($l)) {
                    $log_message = "";
                    foreach ($l as $ln) {
                        $log_message.= "($handle) $ln\n";
                    }
                    $this->log($log_message, GearmanManager::LOG_LEVEL_WORKER_INFO);
                } else {
                    $this->log("($handle) $l", GearmanManager::LOG_LEVEL_WORKER_INFO);
                }

            }
        }


        $result_log = $result;

        if (!is_scalar($result_log)) {
            $result_log = explode("\n", trim(print_r($result_log, true)));
        } elseif (strlen($result_log) > 256) {
            $result_log = substr($result_log, 0, 256)."...(truncated)";
        }

        if (is_array($result_log)) {
            $log_message = "";
            foreach ($result_log as $ln) {
                $log_message.="($handle) $ln\n";
            }
            $this->log($log_message, GearmanManager::LOG_LEVEL_DEBUG);
        } else {
            $this->log("($handle) $result_log", GearmanManager::LOG_LEVEL_DEBUG);
        }
    }
30467
public final void write(T t, MediaType contentType, HttpOutputMessage outputMessage)
			throws IOException, HttpMessageNotWritableException {

		HttpHeaders headers = outputMessage.getHeaders();
		if (headers.getContentType() == null) {
			MediaType contentTypeToUse = contentType;
			if (contentType == null || contentType.isWildcardType() || contentType.isWildcardSubtype()) {
				contentTypeToUse = getDefaultContentType(t);
			}
			if (contentTypeToUse != null) {
				headers.setContentType(contentTypeToUse);
			}
		}
		if (headers.getContentLength() == -1) {
			Long contentLength = getContentLength(t, headers.getContentType());
			if (contentLength != null) {
				headers.setContentLength(contentLength);
			}
		}
		writeInternal(t, outputMessage);
		outputMessage.getBody().flush();
	}
134135
public function write($handle = null)
	{
		if ($handle === null) {
			$handle = fopen('php://output', 'wb');
		} elseif (!is_resource($handle) || get_resource_type($handle) !== 'stream') {
			throw new Exception('Argument must be stream resource.');
		}

		$tables = $views = [];

		$res = $this->connection->query('SHOW FULL TABLES');
		while ($row = $res->fetch_row()) {
			if ($row[1] === 'VIEW') {
				$views[] = $row[0];
			} else {
				$tables[] = $row[0];
			}
		}
		$res->close();

		$tables = array_merge($tables, $views); // views must be last

		$this->connection->query('LOCK TABLES `' . implode('` READ, `', $tables) . '` READ');

		$db = $this->connection->query('SELECT DATABASE()')->fetch_row();
		fwrite($handle, '-- Created at ' . date('j.n.Y G:i') . " using David Grudl MySQL Dump Utility\n"
			. (isset($_SERVER['HTTP_HOST']) ? "-- Host: $_SERVER[HTTP_HOST]\n" : '')
			. '-- MySQL Server: ' . $this->connection->server_info . "\n"
			. '-- Database: ' . $db[0] . "\n"
			. "\n"
			. "SET NAMES utf8;\n"
			. "SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO';\n"
			. "SET FOREIGN_KEY_CHECKS=0;\n"
			. "SET UNIQUE_CHECKS=0;\n"
			. "SET AUTOCOMMIT=0;\n"
		);

		foreach ($tables as $table) {
			$this->dumpTable($handle, $table);
		}

		fwrite($handle, "COMMIT;\n");
		fwrite($handle, "-- THE END\n");

		$this->connection->query('UNLOCK TABLES');
	}
636475
protected function writeln(OutputInterface $output = null, $message)
    {
        if ($output instanceof OutputInterface) {
            $output->writeln($message);
        }
    }
1257311
public function executeCommand(&$output)
	{
		$descriptorspec = array(
			0 => array("pipe", "r"), // stdin is a pipe that the child will read from
			1 => array("pipe", "w"), // stdout is a pipe that the child will write to
			2 => array("pipe", "w") // stderr is a pipe that the child will write to
		);

		$process = proc_open($this->cmd . ' ' . $this->getParams() . ' ' . $this->getInputSource() . ' ' . $this->getPDFPath(), $descriptorspec, $pipes);

		$output = stream_get_contents($pipes[1]) . stream_get_contents($pipes[2]);

		fclose($pipes[0]);
		fclose($pipes[1]);
		fclose($pipes[2]);

		return proc_close($process);
	}