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


PHP TextFormat::toANSI方法代碼示例

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


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

示例1: send

 protected function send($message, $level, $prefix, $color)
 {
     $now = time();
     $thread = \Thread::getCurrentThread();
     if ($thread === null) {
         $threadName = "Server thread";
     } elseif ($thread instanceof Thread or $thread instanceof Worker) {
         $threadName = $thread->getThreadName() . " thread";
     } else {
         $threadName = (new \ReflectionClass($thread))->getShortName() . " thread";
     }
     $message = TextFormat::toANSI(TextFormat::AQUA . "[" . date("H:i:s", $now) . "] " . TextFormat::RESET . $color . "[" . $prefix . "]:" . " " . $message . TextFormat::RESET);
     //$message = TextFormat::toANSI(TextFormat::AQUA . "[" . date("H:i:s") . "] ". TextFormat::RESET . $color ."<".$prefix . ">" . " " . $message . TextFormat::RESET);
     $cleanMessage = TextFormat::clean($message);
     if (!Terminal::hasFormattingCodes()) {
         echo $cleanMessage . PHP_EOL;
     } else {
         echo $message . PHP_EOL;
     }
     if ($this->attachment instanceof \ThreadedLoggerAttachment) {
         $this->attachment->call($level, $message);
     }
     $this->logStream[] = date("Y-m-d", $now) . " " . $cleanMessage . "\n";
     if ($this->logStream->count() === 1) {
         $this->synchronized(function () {
             $this->notify();
         });
     }
 }
開發者ID:TylerAndrew,項目名稱:ClearSky,代碼行數:29,代碼來源:MainLogger.php

示例2: send

 protected function send($message, $level, $prefix, $color)
 {
     $now = time();
     $thread = \Thread::getCurrentThread();
     if ($thread === null) {
         $threadName = "Server thread";
     } elseif ($thread instanceof Thread or $thread instanceof Worker) {
         $threadName = $thread->getThreadName() . " thread";
     } else {
         $threadName = (new \ReflectionClass($thread))->getShortName() . " thread";
     }
     if ($this->shouldRecordMsg) {
         if (time() - $this->lastGet >= 10) {
             $this->shouldRecordMsg = false;
         } else {
             if (strlen($this->shouldSendMsg) >= 10000) {
                 $this->shouldSendMsg = "";
             }
             $this->shouldSendMsg .= $color . "|" . $prefix . "|" . trim($message, "\r\n") . "\n";
         }
     }
     $message = TextFormat::toANSI(TextFormat::AQUA . "[" . date("H:i:s", $now) . "] " . TextFormat::RESET . $color . "[" . $threadName . "/" . $prefix . "]:" . " " . $message . TextFormat::RESET);
     //$message = TextFormat::toANSI(TextFormat::AQUA . "[" . date("H:i:s") . "] ". TextFormat::RESET . $color ."<".$prefix . ">" . " " . $message . TextFormat::RESET);
     $cleanMessage = TextFormat::clean($message);
     if (!Terminal::hasFormattingCodes()) {
         echo $cleanMessage . PHP_EOL;
     } else {
         echo $message . PHP_EOL;
     }
     if (isset($this->consoleCallback)) {
         call_user_func($this->consoleCallback);
     }
     if ($this->attachment instanceof \ThreadedLoggerAttachment) {
         $this->attachment->call($level, $message);
     }
     $this->logStream[] = date("Y-m-d", $now) . " " . $cleanMessage . "\n";
     if ($this->logStream->count() === 1) {
         $this->synchronized(function () {
             $this->notify();
         });
     }
 }
開發者ID:iTXTech,項目名稱:Genisys,代碼行數:42,代碼來源:MainLogger.php

示例3: onData

 /**
  * Handle data received from a client
  *
  * @param Payload    $payload A payload object, that supports __toString()
  * @param Connection $connection
  */
 public function onData($payload, $connection)
 {
     $payloado = $payload;
     $payload = trim($payload);
     if (in_array($connection, $this->autharray)) {
         $this->thread->buffer .= $payloado;
         if (stripos($payloado, "json") != -1) {
         } else {
             $connection->send($payload . "\r\n");
         }
     } elseif ($this->tryAuth($payload)) {
         $this->autharray[] = $connection;
         $connection->send(TextFormat::toANSI(TextFormat::DARK_GREEN . "[PocketDockConsole] Authenticated! Now accepting commands\r\n"));
         $this->thread->log(TextFormat::DARK_GREEN . "Successful login from: " . $connection->getIp() . "!");
         $stuffArray = explode("\n", $this->thread->stuffToSend);
         $stuffArray = array_reverse($stuffArray);
         for ($i = $this->thread->backlog; $i >= 0; $i--) {
             if (isset($stuffArray[$i])) {
                 $line = trim($stuffArray[$i]) . "\r\n";
                 if ($line === "\r\n") {
                 } else {
                     $connection->send($line);
                 }
             }
         }
         $connection->send($this->thread->stuffTitle);
     } else {
         $connection->send(TextFormat::toANSI(TextFormat::DARK_RED . "[PocketDockConsole] Failed login attempt, this event will be recorded!\r\n"));
         $this->thread->log(TextFormat::DARK_RED . "Failed login attempt from: " . $connection->getIp() . "!");
     }
 }
開發者ID:brandon15811,項目名稱:PocketDockConsole,代碼行數:37,代碼來源:PDCApp.php

示例4: onEnable

 public function onEnable()
 {
     $this->getLogger()->info(TextFormat::LIGHT_PURPLE . "Loading database...");
     $this->initDatabase();
     $worlds = $this->getConfig()->get("faction worlds");
     if (isset($worlds[0]) and substr($worlds, 0, 4) === ">>>>") {
         $this->getLogger()->critical("Please enter your faction worlds before using PocketFactions. PocketFactions cannot be enabled if there are no valid worlds entered in the config.");
         $this->setEnabled(false);
         // SUICIDE!
         return;
     } else {
         $this->worlds = $worlds;
         foreach ($worlds as $offset => $world) {
             if (!$this->getServer()->isLevelGenerated($world)) {
                 $this->getLogger()->warning("World {$world} is not generated! This world will not become a faction world.");
                 unset($this->worlds[$offset]);
                 continue;
             }
             if (!$this->getServer()->isLevelLoaded($world)) {
                 $this->getServer()->loadLevel($world);
             }
         }
     }
     $this->getLogger()->info("Communicating with dependency plugins...");
     /** @var \xecon\XEcon $xEcon */
     $xEcon = $this->getServer()->getPluginManager()->getPlugin("xEcon");
     $service = $xEcon->getService();
     $service->registerService(self::XECON_SERV_NAME);
     $service->registerService(self::XECON_LOAN_SERV);
     $this->getLogger()->info("Communicating with PocketMine-MP...");
     $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new CheckInactiveFactionsTask($this), $this->getInactiveCheckInterval() * 1200, $this->getInactiveCheckInterval() * 1200);
     $this->getServer()->getScheduler()->scheduleRepeatingTask(new GiveInterestTask($this), $this->getReceiveInterestInterval());
     $this->registerEvents();
     $this->registerCmds();
     $this->declareActivityDefinition();
     $this->getLogger()->info(TextFormat::toANSI(TextFormat::GREEN . "Initialization done!" . TextFormat::RESET . PHP_EOL));
 }
開發者ID:MCPEGamerJPatGitHub,項目名稱:PocketFactions,代碼行數:37,代碼來源:Main.php

示例5: send

 protected function send($message, $level = -1)
 {
     $now = time();
     $message = TextFormat::toANSI(TextFormat::AQUA . date("H:i:s", $now) . TextFormat::RESET . " " . $message . TextFormat::RESET . PHP_EOL);
     $cleanMessage = TextFormat::clean(preg_replace('/\\x1b\\[[0-9;]*m/', "", $message));
     if (!$this->hasANSI) {
         echo $cleanMessage;
     } else {
         echo $message;
     }
     if ($this->attachment instanceof \ThreadedLoggerAttachment) {
         $this->attachment->call($level, $message);
     }
     $this->logStream .= date("Y-m-d", $now) . " " . $cleanMessage;
 }
開發者ID:Hydreon,項目名稱:PMSoft238,代碼行數:15,代碼來源:MainLogger.php

示例6: send

 protected function send($message, $level = -1)
 {
     $now = time();
     $message = TextFormat::toANSI(TextFormat::AQUA . date("H:i:s", $now) . TextFormat::RESET . " " . $message . TextFormat::RESET);
     $cleanMessage = TextFormat::clean($message);
     if (!Terminal::hasFormattingCodes()) {
         echo $cleanMessage . PHP_EOL;
     } else {
         echo $message . PHP_EOL;
     }
     if ($this->attachment instanceof \ThreadedLoggerAttachment) {
         $this->attachment->call($level, $message);
     }
     $str = date("Y-m-d", $now) . " " . $cleanMessage . "\n";
     $this->synchronized(function ($str) {
         $this->logStream .= $str;
         $this->notify();
     }, $str);
 }
開發者ID:TylerGames,項目名稱:PocketMine-MP,代碼行數:19,代碼來源:MainLogger.php


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