當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Console::streamSupportsAnsiColors方法代碼示例

本文整理匯總了PHP中yii\helpers\Console::streamSupportsAnsiColors方法的典型用法代碼示例。如果您正苦於以下問題:PHP Console::streamSupportsAnsiColors方法的具體用法?PHP Console::streamSupportsAnsiColors怎麽用?PHP Console::streamSupportsAnsiColors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yii\helpers\Console的用法示例。


在下文中一共展示了Console::streamSupportsAnsiColors方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: stderr

 protected function stderr($string)
 {
     if (Console::streamSupportsAnsiColors(\STDOUT)) {
         $string = Console::ansiFormat("    Error: " . $string, [Console::FG_RED]);
     }
     return fwrite(\STDERR, $string);
 }
開發者ID:inblank,項目名稱:yii2-activeuser,代碼行數:7,代碼來源:Migration.php

示例2: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $this->stderrIsNotStdout = fstat(\STDERR)['dev'] != fstat(\STDOUT)['dev'];
     $this->stderrSupportsColors = Console::streamSupportsAnsiColors(\STDERR);
     $this->stdoutSupportsColors = Console::streamSupportsAnsiColors(\STDOUT);
 }
開發者ID:ivan-chkv,項目名稱:yii2-boost,代碼行數:10,代碼來源:StdoutTarget.php

示例3: formatMessage

 /**
  * 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)) {
         $message = Console::ansiFormat($message, $format);
     }
     return $message;
 }
開發者ID:Jaaviieer,項目名稱:PrograWeb,代碼行數:16,代碼來源:ErrorHandler.php

示例4: stdout

 public function stdout($string)
 {
     if (Console::streamSupportsAnsiColors(STDOUT)) {
         $args = func_get_args();
         array_shift($args);
         $string = Console::ansiFormat($string, $args);
     }
     return Console::stdout($string);
 }
開發者ID:filsh,項目名稱:yii2-platform,代碼行數:9,代碼來源:HostRegexpConsoleRule.php

示例5: init

 public function init()
 {
     $this->_stdoutIsTerminal = posix_isatty(\STDOUT);
     if ($this->_stdoutIsTerminal) {
         $this->logVars = [];
     }
     $this->_stdoutSupportsAnsiColors = Console::streamSupportsAnsiColors(\STDOUT);
     $this->_stderrIsTerminal = posix_isatty(\STDERR);
     $this->_stderrSupportsAnsiColors = Console::streamSupportsAnsiColors(\STDERR);
     $this->_levelAnsiColorMap = [Logger::LEVEL_ERROR => $this->errorAnsiColor, Logger::LEVEL_WARNING => $this->warningAnsiColor, Logger::LEVEL_INFO => $this->infoAnsiColor, Logger::LEVEL_TRACE => $this->traceAnsiColor, Logger::LEVEL_PROFILE => $this->profileAnsiColor, Logger::LEVEL_PROFILE_BEGIN => $this->profileBeginAnsiColor, Logger::LEVEL_PROFILE_END => $this->profileEndAnsiColor];
     parent::init();
 }
開發者ID:ivan-chkv,項目名稱:yii2-kladovka,代碼行數:12,代碼來源:StdoutTarget.php

示例6: isColorEnabled

 /**
  * Returns a value indicating whether ANSI color is enabled.
  *
  * ANSI color is enabled only if [[color]] is set true or is not set
  * and the terminal supports ANSI color.
  *
  * @param resource $stream the stream to check.
  * @return boolean Whether to enable ANSI style in output.
  */
 public function isColorEnabled($stream = \STDOUT)
 {
     return $this->color === null ? Console::streamSupportsAnsiColors($stream) : $this->color;
 }
開發者ID:avron99,項目名稱:delayed-orders,代碼行數:13,代碼來源:Controller.php

示例7: stdout

 /**
  * Prints a string to STDOUT
  * @param string $string
  */
 public function stdout($string)
 {
     if (Yii::$app->request->isConsoleRequest) {
         if (Console::streamSupportsAnsiColors(STDOUT)) {
             $args = func_get_args();
             array_shift($args);
             $string = Console::ansiFormat($string, $args);
         }
         Console::stdout($string . "\n");
     }
 }
開發者ID:maxxer,項目名稱:yii2-translate-manager,代碼行數:15,代碼來源:Scanner.php

示例8: generateLabel

 /**
  * @param $message
  *
  * @return string
  */
 private function generateLabel($message)
 {
     $label = '';
     //Add date to log
     if (true == $this->displayDate) {
         $label .= '[' . date($this->dateFormat, time()) . ']';
     }
     //Add category to label
     if (true == $this->displayCategory) {
         $label .= "[" . $message[2] . "]";
     }
     $level = Logger::getLevelName($message[1]);
     $tmpLevel = "[{$level}]";
     if (Console::streamSupportsAnsiColors(\STDOUT)) {
         if (isset($this->color[$level])) {
             $tmpLevel = Console::ansiFormat($tmpLevel, [$this->color[$level]]);
         } else {
             $tmpLevel = Console::ansiFormat($tmpLevel, [Console::BOLD]);
         }
     }
     $label .= $tmpLevel;
     return $label;
 }
開發者ID:wirwolf,項目名稱:yii2-consolelog,代碼行數:28,代碼來源:ConsoleTarget.php

示例9: _isColorEnabled

 /**
  * Returns a value indicating whether ANSI color is enabled.
  *
  * ANSI color is enabled only if [[color]] is set true or is not set
  * and the terminal supports ANSI color.
  *
  * @param resource $stream the stream to check.
  * @return boolean Whether to enable ANSI style in output.
  */
 private function _isColorEnabled($stream = \STDOUT)
 {
     return $this->controller->color === null ? Console::streamSupportsAnsiColors($stream) : $this->controller->color;
 }
開發者ID:qubbDev,項目名稱:yii2-daemonize,代碼行數:13,代碼來源:Process.php


注:本文中的yii\helpers\Console::streamSupportsAnsiColors方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。