mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 01:39:52 +00:00
MainLogger can now have debug level disabled
This commit is contained in:
parent
7bd6f2ed91
commit
8d40f843cf
@ -82,7 +82,6 @@ use pocketmine\tile\Sign;
|
||||
use pocketmine\tile\Spawnable;
|
||||
use pocketmine\tile\Tile;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\MainLogger;
|
||||
use pocketmine\utils\TextFormat;
|
||||
|
||||
/**
|
||||
@ -2128,7 +2127,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->currentTransaction = null;
|
||||
}
|
||||
|
||||
@ -2136,7 +2134,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
}
|
||||
|
||||
|
||||
|
||||
break;
|
||||
case ProtocolInfo::SEND_INVENTORY_PACKET: //TODO, Mojang, enable this ´^_^`
|
||||
if($this->spawned === false){
|
||||
@ -2374,6 +2371,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
return $cnt;
|
||||
}else{
|
||||
$this->removeWindow($inventory);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,6 @@ namespace pocketmine {
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\LogLevel;
|
||||
use pocketmine\utils\MainLogger;
|
||||
use pocketmine\utils\TextFormat;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\wizard\Installer;
|
||||
|
||||
@ -210,25 +209,6 @@ namespace pocketmine {
|
||||
return true;
|
||||
}
|
||||
|
||||
function log($message, $name, $EOL = true, $level = 2, $close = false){
|
||||
global $fpointers;
|
||||
if((!defined("pocketmine\\DEBUG") or \pocketmine\DEBUG >= $level) and (!defined("pocketmine\\LOG") or \pocketmine\LOG === true)){
|
||||
$message .= $EOL === true ? PHP_EOL : "";
|
||||
if(!isset($fpointers)){
|
||||
$fpointers = [];
|
||||
}
|
||||
if(!isset($fpointers[$name]) or $fpointers[$name] === false){
|
||||
$fpointers[$name] = @fopen(\pocketmine\DATA . "/" . $name . ".log", "ab");
|
||||
}
|
||||
@fwrite($fpointers[$name], $message);
|
||||
if($close === true){
|
||||
fclose($fpointers[$name]);
|
||||
unset($fpointers[$name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
set_error_handler("\\pocketmine\\error_handler", E_ALL);
|
||||
|
||||
$errors = 0;
|
||||
|
@ -85,6 +85,7 @@ use pocketmine\tile\Tile;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\Config;
|
||||
use pocketmine\utils\Logger;
|
||||
use pocketmine\utils\MainLogger;
|
||||
use pocketmine\utils\TextFormat;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\utils\VersionString;
|
||||
@ -1275,6 +1276,9 @@ class Server{
|
||||
}
|
||||
|
||||
define("pocketmine\\DEBUG", $this->getConfigInt("debug.level", 1));
|
||||
if($this->logger instanceof MainLogger){
|
||||
$this->logger->setLogDebug(\pocketmine\DEBUG > 1);
|
||||
}
|
||||
define("ADVANCED_CACHE", $this->getConfigBoolean("enable-advanced-cache", false));
|
||||
define("MAX_CHUNK_RATE", 20 / $this->getConfigInt("max-chunks-per-second", 7)); //Default rate ~448 kB/s
|
||||
if(ADVANCED_CACHE == true){
|
||||
@ -1311,7 +1315,6 @@ class Server{
|
||||
$this->enablePlugins(PluginLoadOrder::STARTUP);
|
||||
|
||||
|
||||
|
||||
Generator::addGenerator("pocketmine\\level\\generator\\Flat", "flat");
|
||||
Generator::addGenerator("pocketmine\\level\\generator\\Normal", "normal");
|
||||
Generator::addGenerator("pocketmine\\level\\generator\\Normal", "default");
|
||||
|
@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
|
||||
|
||||
|
@ -24,11 +24,9 @@
|
||||
*/
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\metadata\Metadatable;
|
||||
use pocketmine\metadata\MetadataValue;
|
||||
use pocketmine\Player;
|
||||
|
@ -21,11 +21,8 @@
|
||||
|
||||
namespace pocketmine\block;
|
||||
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
|
||||
|
@ -134,6 +134,7 @@ class DroppedItem extends Entity{
|
||||
public function getData(){
|
||||
$flags = 0;
|
||||
$flags |= $this->fireTicks > 0 ? 1 : 0;
|
||||
|
||||
return [
|
||||
0 => array("type" => 0, "value" => $flags),
|
||||
1 => array("type" => 1, "value" => 0),
|
||||
|
@ -24,6 +24,7 @@
|
||||
*/
|
||||
namespace pocketmine\entity;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\event\entity\EntityDespawnEvent;
|
||||
use pocketmine\event\entity\EntityLevelChangeEvent;
|
||||
use pocketmine\event\entity\EntityMotionEvent;
|
||||
@ -40,16 +41,15 @@ use pocketmine\nbt\tag\Byte;
|
||||
use pocketmine\nbt\tag\Compound;
|
||||
use pocketmine\nbt\tag\Float;
|
||||
use pocketmine\nbt\tag\Short;
|
||||
use pocketmine\Network;
|
||||
use pocketmine\network\protocol\MoveEntityPacket_PosRot;
|
||||
use pocketmine\network\protocol\MovePlayerPacket;
|
||||
use pocketmine\network\protocol\RemoveEntityPacket;
|
||||
use pocketmine\network\protocol\SetEntityMotionPacket;
|
||||
use pocketmine\network\protocol\SetTimePacket;
|
||||
use pocketmine\Network;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\plugin\Plugin;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\block\Block;
|
||||
|
||||
abstract class Entity extends Position implements Metadatable{
|
||||
public static $entityCount = 1;
|
||||
@ -330,11 +330,13 @@ abstract class Entity extends Position implements Metadatable{
|
||||
|
||||
if($direction === 0){
|
||||
$this->motionX = -$force;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if($direction === 1){
|
||||
$this->motionX = $force;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -342,11 +344,13 @@ abstract class Entity extends Position implements Metadatable{
|
||||
|
||||
if($direction === 3){
|
||||
$this->motionY = $force;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if($direction === 4){
|
||||
$this->motionZ = -$force;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -363,6 +367,7 @@ abstract class Entity extends Position implements Metadatable{
|
||||
//TODO: check vehicles
|
||||
if($this->dead === true){
|
||||
$this->close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -461,6 +466,7 @@ abstract class Entity extends Position implements Metadatable{
|
||||
|
||||
$hasUpdate = $this->entityBaseTick();
|
||||
$this->updateMovement();
|
||||
|
||||
//if($this->isStatic())
|
||||
return true;
|
||||
//return !($this instanceof Player);
|
||||
|
@ -24,16 +24,15 @@ namespace pocketmine\entity;
|
||||
use pocketmine\inventory\InventoryHolder;
|
||||
use pocketmine\inventory\PlayerInventory;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\nbt\NBT;
|
||||
use pocketmine\nbt\tag\Byte;
|
||||
use pocketmine\nbt\tag\Compound;
|
||||
use pocketmine\nbt\tag\Enum;
|
||||
use pocketmine\nbt\tag\Short;
|
||||
use pocketmine\Network;
|
||||
use pocketmine\network\protocol\AddPlayerPacket;
|
||||
use pocketmine\network\protocol\RemovePlayerPacket;
|
||||
use pocketmine\network\protocol\SetEntityMotionPacket;
|
||||
use pocketmine\Network;
|
||||
use pocketmine\Player;
|
||||
|
||||
class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
|
@ -20,12 +20,11 @@
|
||||
*/
|
||||
|
||||
namespace pocketmine\event\inventory;
|
||||
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\event\Event;
|
||||
use pocketmine\inventory\Inventory;
|
||||
use pocketmine\inventory\CraftingTransactionGroup;
|
||||
use pocketmine\inventory\Recipe;
|
||||
use pocketmine\Player;
|
||||
|
||||
class CraftItemEvent extends Event implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
|
@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
namespace pocketmine\event\inventory;
|
||||
|
||||
use pocketmine\inventory\Inventory;
|
||||
use pocketmine\Player;
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
namespace pocketmine\event\inventory;
|
||||
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\inventory\Inventory;
|
||||
use pocketmine\Player;
|
||||
|
@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
namespace pocketmine\event\inventory;
|
||||
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\inventory\Inventory;
|
||||
use pocketmine\item\Item;
|
||||
|
@ -20,11 +20,10 @@
|
||||
*/
|
||||
|
||||
namespace pocketmine\event\inventory;
|
||||
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\event\Event;
|
||||
use pocketmine\inventory\Inventory;
|
||||
use pocketmine\inventory\TransactionGroup;
|
||||
use pocketmine\Player;
|
||||
|
||||
/**
|
||||
* Called when there is a transaction between two Inventory objects.
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
namespace pocketmine\event\player;
|
||||
|
||||
use pocketmine\Event;
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\Event;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\Player;
|
||||
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
namespace pocketmine\event\server;
|
||||
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\event;
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\network\protocol\DataPacket;
|
||||
use pocketmine\Player;
|
||||
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
namespace pocketmine\event\server;
|
||||
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\event;
|
||||
use pocketmine\event\Cancellable;
|
||||
use pocketmine\network\protocol\DataPacket;
|
||||
use pocketmine\Player;
|
||||
|
||||
|
@ -133,6 +133,7 @@ abstract class BaseInventory implements Inventory{
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new EntityInventoryChangeEvent($holder, $this->getItem($index), $item, $index));
|
||||
if($ev->isCancelled()){
|
||||
$this->sendContents($this->getViewers());
|
||||
|
||||
return false;
|
||||
}
|
||||
$item = $ev->getNewItem();
|
||||
@ -220,6 +221,7 @@ abstract class BaseInventory implements Inventory{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -258,6 +260,7 @@ abstract class BaseInventory implements Inventory{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $slots;
|
||||
}
|
||||
|
||||
@ -353,6 +356,7 @@ abstract class BaseInventory implements Inventory{
|
||||
return false;
|
||||
}
|
||||
$this->onOpen($who);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -21,10 +21,10 @@
|
||||
|
||||
namespace pocketmine\inventory;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\protocol\ContainerClosePacket;
|
||||
use pocketmine\network\protocol\ContainerOpenPacket;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\math\Vector3;
|
||||
|
||||
abstract class ContainerInventory extends BaseInventory{
|
||||
public function onOpen(Player $who){
|
||||
|
@ -22,7 +22,6 @@
|
||||
namespace pocketmine\inventory;
|
||||
|
||||
use pocketmine\block\Planks;
|
||||
use pocketmine\block\Slab;
|
||||
use pocketmine\block\Wood;
|
||||
use pocketmine\item\Item;
|
||||
|
||||
@ -414,6 +413,7 @@ class CraftingManager{
|
||||
if($checkResult->equals($result, true) and $checkResult->getCount() === $result->getCount()){
|
||||
return $recipe;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -64,6 +64,7 @@ class CraftingTransactionGroup extends SimpleTransactionGroup{
|
||||
*/
|
||||
public function getResult(){
|
||||
reset($this->output);
|
||||
|
||||
return current($this->output);
|
||||
}
|
||||
|
||||
@ -71,6 +72,7 @@ class CraftingTransactionGroup extends SimpleTransactionGroup{
|
||||
if(count($this->output) !== 1 or count($this->input) === 0){
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getMatchingRecipe() instanceof Recipe;
|
||||
}
|
||||
|
||||
@ -81,6 +83,7 @@ class CraftingTransactionGroup extends SimpleTransactionGroup{
|
||||
if($this->recipe === null){
|
||||
$this->recipe = Server::getInstance()->getCraftingManager()->matchTransaction($this);
|
||||
}
|
||||
|
||||
return $this->recipe;
|
||||
}
|
||||
|
||||
@ -94,6 +97,7 @@ class CraftingTransactionGroup extends SimpleTransactionGroup{
|
||||
foreach($this->inventories as $inventory){
|
||||
$inventory->sendContents($inventory->getViewers());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -90,6 +90,7 @@ class ShapedRecipe implements Recipe{
|
||||
$ingredients[$key] = $ingredient;
|
||||
}
|
||||
}
|
||||
|
||||
return $ingredients;
|
||||
}
|
||||
|
||||
|
@ -77,6 +77,7 @@ class ShapelessRecipe implements Recipe{
|
||||
$item->setCount($item->getCount() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -88,6 +89,7 @@ class ShapelessRecipe implements Recipe{
|
||||
foreach($this->ingredients as $ingredient){
|
||||
$ingredients[] = clone $ingredient;
|
||||
}
|
||||
|
||||
return $ingredients;
|
||||
}
|
||||
|
||||
@ -99,6 +101,7 @@ class ShapelessRecipe implements Recipe{
|
||||
foreach($this->ingredients as $ingredient){
|
||||
$count += $ingredient->getCount();
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
|
@ -126,6 +126,7 @@ class SimpleTransactionGroup implements TransactionGroup{
|
||||
$haveItems = [];
|
||||
$needItems = [];
|
||||
$this->matchItems($haveItems, $needItems);
|
||||
|
||||
return count($haveItems) === 0 and count($needItems) === 0 and count($this->transactions) > 0;
|
||||
}
|
||||
|
||||
@ -139,6 +140,7 @@ class SimpleTransactionGroup implements TransactionGroup{
|
||||
foreach($this->inventories as $inventory){
|
||||
$inventory->sendContents($inventory->getViewers());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,6 @@
|
||||
|
||||
namespace pocketmine\inventory;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
|
||||
interface TransactionGroup{
|
||||
|
||||
/**
|
||||
|
@ -440,6 +440,7 @@ class Item{
|
||||
}else{
|
||||
$item = new Item($id, $meta, $count);
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,6 @@ use pocketmine\event\entity\EntityExplodeEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3 as Vector3;
|
||||
use pocketmine\network\protocol\ExplodePacket;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
|
||||
class Explosion{
|
||||
|
@ -33,7 +33,6 @@ use pocketmine\event\block\BlockPlaceEvent;
|
||||
use pocketmine\event\player\PlayerInteractEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\format\pmf\LevelFormat;
|
||||
use pocketmine\level\generator\Flat;
|
||||
use pocketmine\level\generator\Generator;
|
||||
use pocketmine\math\AxisAlignedBB;
|
||||
use pocketmine\math\Vector2;
|
||||
@ -536,6 +535,7 @@ class Level{
|
||||
|
||||
public function isFullBlock(Vector3 $pos){
|
||||
$bb = $this->getBlock($pos)->getBoundingBox();
|
||||
|
||||
return $bb instanceof AxisAlignedBB and $bb->getAverageEdgeLength() >= 1;
|
||||
}
|
||||
|
||||
@ -772,6 +772,7 @@ class Level{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -825,6 +826,7 @@ class Level{
|
||||
$hand->position($block);
|
||||
}elseif($block->getID() === Item::FIRE){
|
||||
$this->setBlock($block, new Air(), true, false, true);
|
||||
|
||||
return false;
|
||||
}else{
|
||||
return false;
|
||||
@ -884,6 +886,7 @@ class Level{
|
||||
if($item->getCount() <= 0){
|
||||
$item = Item::get(Item::AIR, 0, 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@ class BlockMetadataStore extends MetadataStore{
|
||||
if(!($block instanceof Block)){
|
||||
throw new \InvalidArgumentException("Argument must be a Block instance");
|
||||
}
|
||||
|
||||
return $block->x . ":" . $block->y . ":" . $block->z . ":" . $metadataKey;
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ class EntityMetadataStore extends MetadataStore{
|
||||
if(!($entity instanceof Entity)){
|
||||
throw new \InvalidArgumentException("Argument must be an Entity instance");
|
||||
}
|
||||
|
||||
return $entity->getID() . ":" . $metadataKey;
|
||||
}
|
||||
}
|
@ -29,6 +29,7 @@ class LevelMetadataStore extends MetadataStore{
|
||||
if(!($level instanceof Level)){
|
||||
throw new \InvalidArgumentException("Argument must be a Level instance");
|
||||
}
|
||||
|
||||
return strtolower($level->getName()) . ":" . $metadataKey;
|
||||
}
|
||||
}
|
@ -29,6 +29,7 @@ class PlayerMetadataStore extends MetadataStore{
|
||||
if(!($player instanceof OfflinePlayer)){
|
||||
throw new \InvalidArgumentException("Argument must be an OfflinePlayer instance");
|
||||
}
|
||||
|
||||
return strtolower($player->getName()) . ":" . $metadataKey;
|
||||
}
|
||||
}
|
@ -52,6 +52,7 @@ class PluginDescription{
|
||||
|
||||
/**
|
||||
* @param array $plugin
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function loadMap(array $plugin){
|
||||
|
@ -21,12 +21,9 @@
|
||||
|
||||
namespace pocketmine\plugin;
|
||||
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\Logger;
|
||||
use pocketmine\utils\LogLevel;
|
||||
use pocketmine\utils\MainLogger;
|
||||
use pocketmine\utils\TextFormat;
|
||||
|
||||
class PluginLogger implements Logger{
|
||||
|
||||
|
@ -437,6 +437,7 @@ class PluginManager{
|
||||
unset($this->permSubs[$permission][$k]);
|
||||
}
|
||||
}
|
||||
|
||||
return $subs;
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ class MainLogger extends \Thread implements Logger{
|
||||
protected $logStream;
|
||||
protected $shutdown;
|
||||
protected $hasANSI;
|
||||
protected $logDebug;
|
||||
private $logResource;
|
||||
/** @var MainLogger */
|
||||
public static $logger = null;
|
||||
@ -33,10 +34,11 @@ class MainLogger extends \Thread implements Logger{
|
||||
/**
|
||||
* @param string $logFile
|
||||
* @param bool $hasANSI
|
||||
* @param bool $logDebug
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function __construct($logFile, $hasANSI = false){
|
||||
public function __construct($logFile, $hasANSI = false, $logDebug = false){
|
||||
if(static::$logger instanceof MainLogger){
|
||||
throw new \RuntimeException("MainLogger has been already created");
|
||||
}
|
||||
@ -44,6 +46,7 @@ class MainLogger extends \Thread implements Logger{
|
||||
@mkdir(basename($logFile), 0777, true);
|
||||
$this->logFile = $logFile;
|
||||
$this->hasANSI = (bool) $hasANSI;
|
||||
$this->logDebug = (bool) $logDebug;
|
||||
$this->logStream = "";
|
||||
$this->start(PTHREADS_INHERIT_NONE);
|
||||
}
|
||||
@ -84,9 +87,19 @@ class MainLogger extends \Thread implements Logger{
|
||||
}
|
||||
|
||||
public function debug($message){
|
||||
if($this->logDebug === false){
|
||||
return;
|
||||
}
|
||||
$this->send(TextFormat::GRAY . "[DEBUG] " . $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $logDebug
|
||||
*/
|
||||
public function setLogDebug($logDebug){
|
||||
$this->logDebug = (bool) $logDebug;
|
||||
}
|
||||
|
||||
public function log($level, $message){
|
||||
switch($level){
|
||||
case LogLevel::EMERGENCY:
|
||||
|
@ -26,6 +26,7 @@ class MainLogger extends \Thread implements Logger{
|
||||
protected $logStream;
|
||||
protected $shutdown;
|
||||
protected $hasANSI;
|
||||
protected $logDebug;
|
||||
private $logResource;
|
||||
/** @var MainLogger */
|
||||
public static $logger = null;
|
||||
@ -33,10 +34,11 @@ class MainLogger extends \Thread implements Logger{
|
||||
/**
|
||||
* @param string $logFile
|
||||
* @param bool $hasANSI
|
||||
* @param bool $logDebug
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function __construct($logFile, $hasANSI = false){
|
||||
public function __construct($logFile, $hasANSI = false, $logDebug = false){
|
||||
if(static::$logger instanceof MainLogger){
|
||||
throw new \RuntimeException("MainLogger has been already created");
|
||||
}
|
||||
@ -44,6 +46,7 @@ class MainLogger extends \Thread implements Logger{
|
||||
@mkdir(basename($logFile), 0777, true);
|
||||
$this->logFile = $logFile;
|
||||
$this->hasANSI = (bool) $hasANSI;
|
||||
$this->logDebug = (bool) $logDebug;
|
||||
$this->logStream = "";
|
||||
$this->start(PTHREADS_INHERIT_NONE);
|
||||
}
|
||||
@ -84,9 +87,19 @@ class MainLogger extends \Thread implements Logger{
|
||||
}
|
||||
|
||||
public function debug($message){
|
||||
if($this->logDebug === false){
|
||||
return;
|
||||
}
|
||||
$this->send(TextFormat::GRAY . "[DEBUG] " . $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $logDebug
|
||||
*/
|
||||
public function setLogDebug($logDebug){
|
||||
$this->logDebug = (bool) $logDebug;
|
||||
}
|
||||
|
||||
public function log($level, $message){
|
||||
switch($level){
|
||||
case LogLevel::EMERGENCY:
|
||||
|
Loading…
x
Reference in New Issue
Block a user