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


PHP Server::getLogger方法代碼示例

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


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

示例1: testSetLogger

 function testSetLogger()
 {
     $server = new Server();
     $logger = new MockLogger();
     $server->setLogger($logger);
     $this->assertEquals($logger, $server->getLogger());
 }
開發者ID:Radiergummi,項目名稱:anacronism,代碼行數:7,代碼來源:PSR3Test.php

示例2: console

 /**
  * Execute commands as console
  *
  * @param Server $server - pocketmine\Server instance
  * @param str[]|str $cmd - commands to execute
  * @param bool $show - show commands being executed
  */
 public static function console($server, $cmd, $show = false)
 {
     if (!is_array($cmd)) {
         $cmd = [$cmd];
     }
     foreach ($cmd as $c) {
         if ($show) {
             $server->getLogger()->info("CMD> {$cmd}");
         }
         $server->dispatchCommand(new ConsoleCommandSender(), $c);
     }
 }
開發者ID:Gabriel865,項目名稱:pocketmine-plugins,代碼行數:19,代碼來源:Cmd.php

示例3: dumpServerMemory

 public function dumpServerMemory($outputFolder, $maxNesting, $maxStringSize)
 {
     gc_disable();
     if (!file_exists($outputFolder)) {
         mkdir($outputFolder, 0777, true);
     }
     $this->server->getLogger()->notice("[Dump] After the memory dump is done, the server might crash");
     $obData = fopen($outputFolder . "/objects.js", "wb+");
     $staticProperties = [];
     $data = [];
     $objects = [];
     $refCounts = [];
     $this->continueDump($this->server, $data, $objects, $refCounts, 0, $maxNesting, $maxStringSize);
     do {
         $continue = false;
         foreach ($objects as $hash => $object) {
             if (!is_object($object)) {
                 continue;
             }
             $continue = true;
             $className = get_class($object);
             $objects[$hash] = true;
             $reflection = new \ReflectionObject($object);
             $info = ["information" => "{$hash}@{$className}", "properties" => []];
             if ($reflection->getParentClass()) {
                 $info["parent"] = $reflection->getParentClass()->getName();
             }
             if (count($reflection->getInterfaceNames()) > 0) {
                 $info["implements"] = implode(", ", $reflection->getInterfaceNames());
             }
             foreach ($reflection->getProperties() as $property) {
                 if ($property->isStatic()) {
                     continue;
                 }
                 if (!$property->isPublic()) {
                     $property->setAccessible(true);
                 }
                 $this->continueDump($property->getValue($object), $info["properties"][$property->getName()], $objects, $refCounts, 0, $maxNesting, $maxStringSize);
             }
             fwrite($obData, "{$hash}@{$className}: " . json_encode($info, JSON_UNESCAPED_SLASHES) . "\n");
             if (!isset($objects["staticProperties"][$className])) {
                 $staticProperties[$className] = [];
                 foreach ($reflection->getProperties() as $property) {
                     if (!$property->isStatic() or $property->getDeclaringClass()->getName() !== $className) {
                         continue;
                     }
                     if (!$property->isPublic()) {
                         $property->setAccessible(true);
                     }
                     $this->continueDump($property->getValue($object), $staticProperties[$className][$property->getName()], $objects, $refCounts, 0, $maxNesting, $maxStringSize);
                 }
             }
         }
         echo "[Dump] Wrote " . count($objects) . " objects\n";
     } while ($continue);
     file_put_contents($outputFolder . "/staticProperties.js", json_encode($staticProperties, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
     file_put_contents($outputFolder . "/serverEntry.js", json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
     file_put_contents($outputFolder . "/referenceCounts.js", json_encode($refCounts, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
     echo "[Dump] Finished!\n";
     gc_enable();
     $this->server->forceShutdown();
 }
開發者ID:MunkySkunk,項目名稱:BukkitPE,代碼行數:62,代碼來源:MemoryManager.php


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