/** * Colorizes a message for console output. * @param string $message the message to colorize. * @param array $format the message format. * @return string the colorized message. * @see Console::ansiFormat() for details on how to specify the message format. */ protected function formatMessage($message, $format = [Console::FG_RED, Console::BOLD]) { $stream = PHP_SAPI === 'cli' ? \STDERR : \STDOUT; // try controller first to allow check for --color switch //if (Yii::$app->controller instanceof \yii\console\Controller && Yii::$app->controller->isColorEnabled($stream) // || Yii::$app instanceof \yii\console\Application && Console::streamSupportsAnsiColors($stream)) { if (Console::stream_supports_ansi_colors($stream)) { $message = Console::ansi_format($message, $format); } return $message; }
public function is_color_enabled($stream = \STDOUT) { return $this->color === null ? Console::stream_supports_ansi_colors($stream) : $this->color; }