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


PHP Console::stdout方法代碼示例

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


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

示例1: stdout

 /**
  * Prints a string to STDOUT.
  *
  * @param string $string the string to print
  * @return int|boolean Number of bytes printed or false on error
  */
 public static function stdout($string)
 {
     $args = func_get_args();
     array_shift($args);
     $string = parent::ansiFormat($string, $args) . "\n";
     return parent::stdout($string);
 }
開發者ID:delagics,項目名稱:yii2-app-another,代碼行數:13,代碼來源:Console.php

示例2: stdout

 /**
  * Prints a string to STDOUT.
  *
  * @param string $string the string to print
  * @return int|boolean Number of bytes printed or false on error
  */
 public function stdout($string)
 {
     if ($this->isColorEnabled()) {
         $args = func_get_args();
         array_shift($args);
         $string = Console::ansiFormat($string, $args) . "\n";
     }
     return Console::stdout($string);
 }
開發者ID:delagics,項目名稱:yii2-app-another,代碼行數:15,代碼來源:Controller.php

示例3: 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

示例4: message

 /**
  * message
  *
  * @param string $string
  * @access private
  * @return integer|null
  */
 private function message($string)
 {
     if (!empty($string) && !$this->quiet) {
         $args = func_get_args();
         array_shift($args);
         $string = Console::ansiFormat($string, $args);
         return Console::stdout($string);
     }
 }
開發者ID:dmitriy-luch,項目名稱:yii2-asset-clean,代碼行數:16,代碼來源:AssetController.php

示例5: log

 /**
  * Logs a message to console and then to yii\log\Logger.
  */
 public function log($message, $level, $category = 'application')
 {
     if ($level <= $this->getSpamLevel()) {
         $style = self::$styles[$level];
         if ($style) {
             $message = Console::ansiFormat($message, $style);
         }
         Console::stdout($message . "\n");
     }
     parent::log($message, $level, $category);
 }
開發者ID:hiqdev,項目名稱:hidev,代碼行數:14,代碼來源:Logger.php

示例6: output

 /**
  * 
  * @param string $string
  * @return string
  */
 public function output($string)
 {
     if ($this->isColorEnabled()) {
         $args = func_get_args();
         array_shift($args);
         $string = Console::ansiFormat($string, $args);
     }
     $b = Console::stdout($string);
     echo PHP_EOL;
     return $b;
 }
開發者ID:jlorente,項目名稱:yii2-app-advanced-template,代碼行數:16,代碼來源:Controller.php

示例7: write

 public static function write($path, $content)
 {
     if (file_exists($path)) {
         $old = file_get_contents($path);
         if ($old === $content) {
             return;
         }
     }
     file_put_contents($path, $content);
     Console::stdout(Console::ansiFormat("written file: {$path}\n", [Console::FG_YELLOW]));
 }
開發者ID:hiqdev,項目名稱:chkipper,代碼行數:11,代碼來源:File.php

示例8: export

 /**
  * @inheritdoc
  */
 public function export()
 {
     foreach ($this->messages as $message) {
         $string = $this->formatMessage($message) . "\n";
         $level = $message[1];
         if ($this->stderrIsNotStdout && in_array($level, $this->stderrLevels)) {
             if ($this->stderrSupportsColors) {
                 Console::stderr(Console::ansiFormat($string, $this->colorMap[$level]));
             } else {
                 Console::stderr($string);
             }
         }
         if ($this->stdoutSupportsColors) {
             Console::stdout(Console::ansiFormat($string, $this->colorMap[$level]));
         } else {
             Console::stdout($string);
         }
     }
 }
開發者ID:ivan-chkv,項目名稱:yii2-boost,代碼行數:22,代碼來源:StdoutTarget.php

示例9: export

 /**
  * Exports log [[messages]] to a specific destination.
  * Child classes must implement this method.
  */
 public function export()
 {
     foreach ($this->messages as $message) {
         list($text, $level, $category, $timestamp) = $message;
         if (!is_string($text)) {
             // exceptions may not be serializable if in the call stack somewhere is a Closure
             if ($text instanceof \Throwable || $text instanceof \Exception) {
                 $text = (string) $text;
             } else {
                 $text = VarDumper::export($text);
             }
         }
         $string = "[{$level}][{$category}] {$text}";
         if ($level == Logger::LEVEL_ERROR) {
             Console::stderr($string);
         } else {
             Console::stdout($string);
         }
     }
 }
開發者ID:hiqdev,項目名稱:asset-packagist,代碼行數:24,代碼來源:StdoutTarget.php

示例10: callback

 public function callback(AMQPMessage $msg)
 {
     $routingKey = $msg->delivery_info['routing_key'];
     $method = 'read' . Inflector::camelize($routingKey);
     if (!isset($this->interpreters[$this->queue])) {
         $interpreter = $this;
     } elseif (class_exists($this->interpreters[$this->queue])) {
         $interpreter = new $this->interpreters[$this->queue]();
         if (!$interpreter instanceof AmqpInterpreter) {
             throw new Exception(sprintf("Class '%s' is not correct interpreter class.", $this->interpreters[$this->queue]));
         }
     } else {
         throw new Exception(sprintf("Interpreter class '%s' was not found.", $this->interpreters[$this->queue]));
     }
     if (method_exists($interpreter, $method)) {
         $info = ['exchange' => $msg->get('exchange'), 'queue' => $this->queue, 'routing_key' => $msg->get('routing_key'), 'reply_to' => $msg->has('reply_to') ? $msg->get('reply_to') : null];
         try {
             $interpreter->{$method}(Json::decode($msg->body, true), $info);
         } catch (\Exception $exc) {
             $error_info = "consumer fail:" . $exc->getMessage() . PHP_EOL . "info:" . print_r($info, true) . PHP_EOL . "body:" . PHP_EOL . print_r($msg->body, true) . PHP_EOL . $exc->getTraceAsString();
             \Yii::warning($error_info, __METHOD__);
             $format = [Console::FG_RED];
             Console::stdout(Console::ansiFormat($error_info . PHP_EOL, $format));
             Console::stdout(Console::ansiFormat($exc->getTraceAsString() . PHP_EOL, $format));
         }
     } else {
         if (!isset($this->interpreters[$this->queue])) {
             $interpreter = new AmqpInterpreter();
         }
         $error_info = "Unknown routing key '{$routingKey}' for exchange '{$this->queue}'.";
         $error_info .= PHP_EOL . $msg->body;
         \Yii::warning($error_info, __METHOD__);
         $interpreter->log(sprintf("Unknown routing key '%s' for exchange '%s'.", $routingKey, $this->queue), $interpreter::MESSAGE_ERROR);
         // debug the message
         $interpreter->log(print_r(Json::decode($msg->body, true), true), $interpreter::MESSAGE_INFO);
     }
 }
開發者ID:hzted123,項目名稱:yii2-amqp,代碼行數:37,代碼來源:AmqpListenerController.php

示例11: export

 public function export()
 {
     foreach ($this->messages as $message) {
         $string = $this->formatMessage($message) . "\n";
         $level = $message[1];
         if ($level == Logger::LEVEL_INFO) {
             if (strncmp('BEGIN ', $message[0], 6) == 0) {
                 $ansiColor = $this->_levelAnsiColorMap[Logger::LEVEL_PROFILE_BEGIN];
             } elseif (strncmp('END ', $message[0], 4) == 0) {
                 $ansiColor = $this->_levelAnsiColorMap[Logger::LEVEL_PROFILE_END];
             } else {
                 $ansiColor = $this->_levelAnsiColorMap[Logger::LEVEL_INFO];
             }
         } elseif (array_key_exists($level, $this->_levelAnsiColorMap)) {
             $ansiColor = $this->_levelAnsiColorMap[$level];
         } else {
             $ansiColor = $this->defaultAnsiColor;
         }
         if ($this->_stdoutIsTerminal) {
             if ($this->_stdoutSupportsAnsiColors && $ansiColor) {
                 Console::stdout(Console::ansiFormat($string, $ansiColor));
             } else {
                 Console::stdout($string);
             }
         } else {
             Console::stdout($string);
             if ($this->_stderrIsTerminal && ($level == Logger::LEVEL_ERROR || $level == Logger::LEVEL_WARNING)) {
                 if ($this->_stderrSupportsAnsiColors && $ansiColor) {
                     Console::stderr(Console::ansiFormat($string, $ansiColor));
                 } else {
                     Console::stderr($string);
                 }
             }
         }
     }
 }
開發者ID:ivan-chkv,項目名稱:yii2-kladovka,代碼行數:36,代碼來源:StdoutTarget.php

示例12: 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

示例13: log

 /**
  * Logs info and error messages.
  *
  * @param $message
  * @param $type
  */
 public static function log($message, $type = self::MESSAGE_INFO)
 {
     $format = [$type == self::MESSAGE_ERROR ? Console::FG_RED : Console::FG_BLUE];
     Console::stdout(Console::ansiFormat($message . PHP_EOL, $format));
 }
開發者ID:hzted123,項目名稱:yii2-amqp,代碼行數:11,代碼來源:AmqpInterpreter.php

示例14: stdout

 /**
  * Prints a string to STDOUT
  *
  * You may optionally format the string with ANSI codes by
  * passing additional parameters using the constants defined in [[\yii\helpers\Console]].
  *
  * Example:
  *
  * ~~~
  * $this->stdout('This will be red and underlined.', Console::FG_RED, Console::UNDERLINE);
  * ~~~
  *
  * @param string $string the string to print
  * @return int|boolean Number of bytes printed or false on error
  */
 public function stdout($string)
 {
     if (Yii::$app->id != 'app-console') {
         return false;
     }
     if ($this->isColorEnabled()) {
         $args = func_get_args();
         array_shift($args);
         $string = Console::ansiFormat($string, $args);
     }
     return Console::stdout($string);
 }
開發者ID:baranov-nt,項目名稱:setyes,代碼行數:27,代碼來源:SourceMessageSearch.php

示例15: chmod

 /**
  * @param string $mode
  * @param string $path
  * @param bool   $recursive
  *
  * @return bool
  */
 public function chmod($mode, $path, $recursive = false)
 {
     switch ($this->_connType) {
         case SftpHelper::TYPE_SFTP:
         default:
             $res = $this->_connection->chmod($mode, $path, $recursive);
             break;
         case SftpHelper::TYPE_FTP:
             if ($recursive) {
                 Console::stdout("\n");
                 Log::throwException('Recursive not supported for chmod in ftp mode');
             }
             $res = @ftp_chmod($this->_connection, $mode, $path);
             break;
     }
     return $res;
 }
開發者ID:giovdk21,項目名稱:deployii,代碼行數:24,代碼來源:SftpHelper.php


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