当前位置: 首页>>代码示例>>PHP>>正文


PHP utils\MainLogger类代码示例

本文整理汇总了PHP中pocketmine\utils\MainLogger的典型用法代码示例。如果您正苦于以下问题:PHP MainLogger类的具体用法?PHP MainLogger怎么用?PHP MainLogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MainLogger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: log

 public static function log($logger, $flag, $msg, $timeout = 5)
 {
     if (isset(self::$msgs[$flag])) {
         if (microtime(true) - self::$msgs[$flag] < $timeout) {
             return;
         }
     }
     self::$msgs[$flag] = microtime(true);
     if ($logger instanceof \Logger) {
         $logger->notice($msg);
     } else {
         MainLogger::getLogger()->notice($msg);
     }
 }
开发者ID:LegionPE,项目名称:LegionPE-Eta,代码行数:14,代码来源:LogCapacitor.php

示例2: __construct

 public function __construct()
 {
     // load recipes from src/pocketmine/recipes.json
     $recipes = new Config(Server::getInstance()->getFilePath() . "src/pocketmine/resources/recipes.json", Config::JSON, []);
     MainLogger::getLogger()->info("Loading recipes...");
     foreach ($recipes->getAll() as $recipe) {
         switch ($recipe["Type"]) {
             case 0:
                 // TODO: handle multiple result items
                 if (count($recipe["Result"]) == 1) {
                     $first = $recipe["Result"][0];
                     $result = new ShapelessRecipe(Item::get($first["ID"], $first["Damage"], $first["Count"]));
                     foreach ($recipe["Ingredients"] as $ingredient) {
                         $result->addIngredient(Item::get($ingredient["ID"], $ingredient["Damage"], $ingredient["Count"]));
                     }
                     $this->registerRecipe($result);
                 }
                 break;
             case 1:
                 // TODO: handle multiple result items
                 if (count($recipe["Result"]) == 1) {
                     $first = $recipe["Result"][0];
                     $result = new ShapedRecipe(Item::get($first["ID"], $first["Damage"], $first["Count"]), $recipe["Height"], $recipe["Width"]);
                     $shape = array_chunk($recipe["Ingredients"], $recipe["Width"]);
                     foreach ($shape as $y => $row) {
                         foreach ($row as $x => $ingredient) {
                             $result->addIngredient($x, $y, Item::get($ingredient["ID"], $ingredient["Damage"] < 0 ? null : $ingredient["Damage"], $ingredient["Count"]));
                         }
                     }
                     $this->registerRecipe($result);
                 }
                 break;
             case 2:
                 $result = $recipe["Result"];
                 $resultItem = Item::get($result["ID"], $result["Damage"], $result["Count"]);
                 $this->registerRecipe(new FurnaceRecipe($resultItem, Item::get($recipe["Ingredients"], 0, 1)));
                 break;
             case 3:
                 $result = $recipe["Result"];
                 $resultItem = Item::get($result["ID"], $result["Damage"], $result["Count"]);
                 $this->registerRecipe(new FurnaceRecipe($resultItem, Item::get($recipe["Ingredients"]["ID"], $recipe["Ingredients"]["Damage"], 1)));
                 break;
             default:
                 break;
         }
     }
 }
开发者ID:ianju,项目名称:PocketMine-MP,代码行数:47,代码来源:CraftingManager.php

示例3: parseInfo

 public function parseInfo()
 {
     $this->seek(0);
     if (fread($this->fp, 3) !== "PMF") {
         return false;
     }
     $this->version = ord($this->read(1));
     switch ($this->version) {
         case 0x1:
             $this->type = ord($this->read(1));
             break;
         default:
             MainLogger::getLogger()->alert("Tried loading non-supported PMF version " . $this->version . " on file " . $this->file);
             return false;
     }
     return true;
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:17,代码来源:PMF.php

示例4: query

 public function query($msg, $fetch, ...$args)
 {
     foreach ($args as &$arg) {
         if (is_string($arg)) {
             $arg = "'" . $this->mysqli->escape_string($arg) . "'";
         } else {
             $arg = "{$arg}";
         }
     }
     if (count($args) > 0) {
         try {
             if ($fetch !== 3) {
                 $result = $this->mysqli->query($query = sprintf($msg, ...$args));
             } else {
                 return sprintf($msg, ...$args);
             }
         } catch (\RuntimeException $e) {
             MainLogger::getLogger()->alert($e->getTraceAsString());
             MainLogger::getLogger()->alert("Query: " . TextFormat::YELLOW . $msg);
             MainLogger::getLogger()->alert("Args: " . var_export($args, true));
             return null;
         }
     } else {
         $result = $this->mysqli->query($query = $msg);
         // to make it faster
     }
     if ($result === false) {
         $server = Server::getInstance();
         $server->getLogger()->warning("Query failed! Query:");
         $server->getLogger()->warning($query);
         $server->getLogger()->warning("Message: " . $this->mysqli->error);
     }
     if ($result instanceof \mysqli_result) {
         if ($fetch === self::ASSOC) {
             return $result->fetch_assoc();
         } elseif ($fetch === self::ALL) {
             return $result->fetch_all(MYSQLI_ASSOC);
         }
         return $result;
     }
     return $result;
 }
开发者ID:LegionPE,项目名称:LegionPE-Eta,代码行数:42,代码来源:MysqlConnection.php

示例5: isset

 \ini_set("display_errors", 1);
 \ini_set("display_startup_errors", 1);
 \ini_set("default_charset", "utf-8");
 \ini_set("memory_limit", -1);
 \define("pocketmine\\START_TIME", \microtime(\true));
 $opts = \getopt("", ["data:", "plugins:", "no-wizard", "enable-profiler"]);
 \define("pocketmine\\DATA", isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR);
 \define("pocketmine\\PLUGIN_PATH", isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR);
 Terminal::init();
 \define("pocketmine\\ANSI", Terminal::hasFormattingCodes());
 if (!\file_exists(\pocketmine\DATA)) {
     \mkdir(\pocketmine\DATA, 0777, \true);
 }
 //Logger has a dependency on timezone, so we'll set it to UTC until we can get the actual timezone.
 \date_default_timezone_set("UTC");
 $logger = new MainLogger(\pocketmine\DATA . "server.log", \pocketmine\ANSI);
 if (!\ini_get("date.timezone")) {
     if ($timezone = detect_system_timezone() and \date_default_timezone_set($timezone)) {
         //Success! Timezone has already been set and validated in the if statement.
         //This here is just for redundancy just in case some program wants to read timezone data from the ini.
         \ini_set("date.timezone", $timezone);
     } else {
         //If system timezone detection fails or timezone is an invalid value.
         if ($response = Utils::getURL("http://ip-api.com/json") and $ip_geolocation_data = \json_decode($response, \true) and $ip_geolocation_data['status'] != 'fail' and \date_default_timezone_set($ip_geolocation_data['timezone'])) {
             //Again, for redundancy.
             \ini_set("date.timezone", $ip_geolocation_data['timezone']);
         } else {
             \ini_set("date.timezone", "UTC");
             \date_default_timezone_set("UTC");
             $logger->warning("Timezone could not be automatically determined. An incorrect timezone will result in incorrect timestamps on console logs. It has been set to \"UTC\" by default. You can change it on the php.ini file.");
         }
开发者ID:VonHirsch,项目名称:PocketMine-0.13.0,代码行数:31,代码来源:PocketMine.php

示例6: disablePlugin

 /**
  * @param Plugin $plugin
  */
 public function disablePlugin(Plugin $plugin)
 {
     if ($plugin instanceof PluginBase and $plugin->isEnabled()) {
         MainLogger::getLogger()->info("Disabling " . $plugin->getDescription()->getFullName());
         Server::getInstance()->getPluginManager()->callEvent(new PluginDisableEvent($plugin));
         $plugin->setEnabled(false);
     }
 }
开发者ID:applqpak,项目名称:plugin-remakes,代码行数:11,代码来源:FolderPluginLoader.php

示例7: tell

 /**
  * Send to the subscriber a message
  * @param string $msg a string message, could be formatted in the sprintf() method
  * @param string ...$args arguments to be formatted in sprintf()
  * @return void
  */
 public function tell($msg, ...$args)
 {
     try {
         MainLogger::getLogger()->info(sprintf($msg, ...$args));
     } catch (\RuntimeException $e) {
         var_dump($msg, $args, $e);
     }
 }
开发者ID:LegionPE,项目名称:LegionPE-Eta,代码行数:14,代码来源:LegionPE.php

示例8: readChunk

 public function readChunk($x, $z, $generate = true, $forward = false)
 {
     $index = self::getChunkOffset($x, $z);
     if ($index < 0 or $index >= 4096) {
         //Regenerate chunk due to corruption
         $this->locationTable[$index][0] = 0;
         $this->locationTable[$index][1] = 1;
     }
     if (!$this->isChunkGenerated($index)) {
         if ($generate === true) {
             //Allocate space
             $this->locationTable[$index][0] = ++$this->lastSector;
             $this->locationTable[$index][1] = 1;
             fseek($this->filePointer, $this->locationTable[$index][0] << 12);
             fwrite($this->filePointer, str_pad(Binary::writeInt(-1) . chr(self::COMPRESSION_ZLIB), 4096, "", STR_PAD_RIGHT));
             $this->writeLocationIndex($index);
         } else {
             return false;
         }
     }
     fseek($this->filePointer, $this->locationTable[$index][0] << 12);
     $length = Binary::readInt(fread($this->filePointer, 4));
     $compression = ord(fgetc($this->filePointer));
     if ($length <= 0) {
         //Not yet generated
         $this->generateChunk($x, $z);
         fseek($this->filePointer, $this->locationTable[$index][0] << 12);
         $length = Binary::readInt(fread($this->filePointer, 4));
         $compression = ord(fgetc($this->filePointer));
     }
     if ($length > $this->locationTable[$index][1] << 12) {
         //Invalid chunk, bigger than defined number of sectors
         MainLogger::getLogger()->error("Corrupted chunk detected");
         $this->locationTable[$index][1] = $length >> 12;
         $this->writeLocationIndex($index);
     } elseif ($compression !== self::COMPRESSION_ZLIB and $compression !== self::COMPRESSION_GZIP) {
         MainLogger::getLogger()->error("Invalid compression type");
         return false;
     }
     $chunk = Chunk::fromBinary(fread($this->filePointer, $length - 1), $this->levelProvider);
     if ($chunk instanceof Chunk) {
         return $chunk;
     } elseif ($forward === false) {
         MainLogger::getLogger()->error("Corrupted chunk detected");
         $this->generateChunk($x, $z);
         return $this->readChunk($x, $z, $generate, true);
     } else {
         return null;
     }
 }
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:50,代码来源:RegionLoader.php

示例9: fromString

 /**
  * @param string $str
  *
  * @return BanEntry
  */
 public static function fromString($str)
 {
     if (strlen($str) < 2) {
         return null;
     } else {
         $str = explode("|", trim($str));
         $entry = new BanEntry(trim(array_shift($str)));
         if (count($str) > 0) {
             $datetime = \DateTime::createFromFormat(self::$format, array_shift($str));
             if (!$datetime instanceof \DateTime) {
                 MainLogger::getLogger()->alert("Error parsing date for BanEntry for player \"" . $entry->getName() . "\", the format may be invalid!");
                 return $entry;
             }
             $entry->setCreated($datetime);
             if (count($str) > 0) {
                 $entry->setSource(trim(array_shift($str)));
                 if (count($str) > 0) {
                     $expire = trim(array_shift($str));
                     if (strtolower($expire) !== "forever" and strlen($expire) > 0) {
                         $entry->setExpires(\DateTime::createFromFormat(self::$format, $expire));
                     }
                     if (count($str) > 0) {
                         $entry->setReason(trim(array_shift($str)));
                     }
                 }
             }
         }
         return $entry;
     }
 }
开发者ID:kniffo80,项目名称:Genisys,代码行数:35,代码来源:BanEntry.php

示例10: sendMessage

 /**
  * @param string $message
  */
 public function sendMessage($message)
 {
     if ($message instanceof TextContainer) {
         $message = $this->getServer()->getLanguage()->translate($message);
     } else {
         $message = $this->getServer()->getLanguage()->translateString($message);
     }
     foreach (explode("\n", trim($message)) as $line) {
         MainLogger::getLogger()->info($line);
     }
 }
开发者ID:ClearSkyTeam,项目名称:ClearSky,代码行数:14,代码来源:ConsoleCommandSender.php

示例11: loadChunk

 public function loadChunk($X, $Z)
 {
     if ($this->isChunkLoaded($X, $Z)) {
         return true;
     }
     $index = self::getIndex($X, $Z);
     $path = $this->getChunkPath($X, $Z);
     if (!file_exists($path)) {
         if ($this->generateChunk($X, $Z) === false) {
             return false;
         }
         if ($this->isGenerating === 0) {
             $this->populateChunk($X, $Z);
         }
         return true;
     }
     $chunk = file_get_contents($path);
     if ($chunk === false) {
         return false;
     }
     $chunk = zlib_decode($chunk);
     $offset = 0;
     $this->chunkInfo[$index] = [0 => ord($chunk[0]), 1 => Binary::readInt(substr($chunk, 1, 4))];
     $offset += 5;
     $len = Binary::readInt(substr($chunk, $offset, 4));
     $offset += 4;
     $nbt = new NBT(NBT::BIG_ENDIAN);
     $nbt->read(substr($chunk, $offset, $len));
     $this->chunkInfo[$index][2] = $nbt->getData();
     $offset += $len;
     $this->chunks[$index] = [];
     $this->chunkChange[$index] = [-1 => false];
     $this->chunkInfo[$index][3] = substr($chunk, $offset, 256);
     //Biome data
     $offset += 256;
     for ($Y = 0; $Y < 8; ++$Y) {
         if (($this->chunkInfo[$index][0] & 1 << $Y) !== 0) {
             // 4096 + 2048 + 2048, Block Data, Meta, Light
             if (strlen($this->chunks[$index][$Y] = substr($chunk, $offset, 8192)) < 8192) {
                 MainLogger::getLogger()->notice("Empty corrupt chunk detected [{$X},{$Z},:{$Y}], recovering contents");
                 $this->fillMiniChunk($X, $Z, $Y);
             }
             $offset += 8192;
         } else {
             $this->chunks[$index][$Y] = false;
         }
     }
     if ($this->isGenerating === 0 and !$this->isPopulated($X, $Z)) {
         $this->populateChunk($X, $Z);
     }
     return true;
 }
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:52,代码来源:LevelFormat.php

示例12: onDisable

 public function onDisable()
 {
     MainLogger::getLogger()->info(TextFormat::LIGHT_PURPLE . "AntiFly disabled.");
 }
开发者ID:ChiefArtz,项目名称:AntiFly,代码行数:4,代码来源:Main.php

示例13: newSession

 /**
  * @param Player $player
  * @param mixed[]|null $loginData
  * @return bool
  */
 public function newSession(Player $player, $loginData = null)
 {
     if ($loginData === null) {
         $player->sendMessage(Phrases::VAR_wait . "Welcome to Legion PE! Please wait while we are preparing to register an account for you.");
         new NewUserQuery($this, $player);
         return false;
     }
     try {
         $this->sessions[$player->getId()] = $this->createSession($player, $loginData);
         return true;
     } catch (\Exception $e) {
         $this->getLogger()->error("An error occurred while trying to initialize session for player {$player->getName()}: ");
         MainLogger::getLogger()->logException($e);
         return false;
     }
 }
开发者ID:legoboy0215,项目名称:LegionPE-Theta-Base,代码行数:21,代码来源:BasePlugin.php

示例14: save

 public function save($flag = \true)
 {
     $this->removeExpired();
     $fp = @\fopen($this->file, "w");
     if (\is_resource($fp)) {
         if ($flag === \true) {
             \fwrite($fp, "# Updated " . \strftime("%x %H:%M", \time()) . " by " . Server::getInstance()->getName() . " " . Server::getInstance()->getPocketMineVersion() . "\n");
             \fwrite($fp, "# victim name | ban date | banned by | banned until | reason\n\n");
         }
         foreach ($this->list as $entry) {
             \fwrite($fp, $entry->getString() . "\n");
         }
         \fclose($fp);
     } else {
         MainLogger::getLogger()->error("Could not save ban list");
     }
 }
开发者ID:xpyctum,项目名称:PocketMinePlusPlus,代码行数:17,代码来源:BanList.php

示例15: readChunk

 public function readChunk($x, $z)
 {
     $index = self::getChunkOffset($x, $z);
     if ($index < 0 or $index >= 4096) {
         return \null;
     }
     $this->lastUsed = \time();
     if (!$this->isChunkGenerated($index)) {
         return \null;
     }
     \fseek($this->filePointer, $this->locationTable[$index][0] << 12);
     $length = \unpack("N", \fread($this->filePointer, 4))[1] << 32 >> 32;
     $compression = \ord(\fgetc($this->filePointer));
     if ($length <= 0 or $length > self::MAX_SECTOR_LENGTH) {
         //Not yet generated / corrupted
         if ($length >= self::MAX_SECTOR_LENGTH) {
             $this->locationTable[$index][0] = ++$this->lastSector;
             $this->locationTable[$index][1] = 1;
             MainLogger::getLogger()->error("Corrupted chunk header detected");
         }
         return \null;
     }
     if ($length > $this->locationTable[$index][1] << 12) {
         //Invalid chunk, bigger than defined number of sectors
         MainLogger::getLogger()->error("Corrupted bigger chunk detected");
         $this->locationTable[$index][1] = $length >> 12;
         $this->writeLocationIndex($index);
     } elseif ($compression !== self::COMPRESSION_ZLIB and $compression !== self::COMPRESSION_GZIP) {
         MainLogger::getLogger()->error("Invalid compression type");
         return \null;
     }
     $chunk = $this->unserializeChunk(\fread($this->filePointer, $length - 1));
     if ($chunk instanceof FullChunk) {
         return $chunk;
     } else {
         MainLogger::getLogger()->error("Corrupted chunk detected");
         return \null;
     }
 }
开发者ID:xpyctum,项目名称:PocketMinePlusPlus,代码行数:39,代码来源:RegionLoader__64bit.php


注:本文中的pocketmine\utils\MainLogger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。