当前位置: 首页>>代码示例>>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;未经允许,请勿转载。