Add some typehints and documentation to MainLogger

This commit is contained in:
Dylan K. Taylor 2017-08-06 11:42:43 +01:00
parent 4e9af1ac45
commit 3fdbcee10f

View File

@ -28,26 +28,31 @@ use pocketmine\Thread;
use pocketmine\Worker; use pocketmine\Worker;
class MainLogger extends \AttachableThreadedLogger{ class MainLogger extends \AttachableThreadedLogger{
/** @var string */
protected $logFile; protected $logFile;
/** @var \Threaded */
protected $logStream; protected $logStream;
/** @var bool */
protected $shutdown; protected $shutdown;
/** @var bool */
protected $logDebug; protected $logDebug;
/** @var MainLogger */ /** @var MainLogger */
public static $logger = null; public static $logger = null;
/** /**
* @param string $logFile * @param string $logFile
* @param bool $logDebug * @param bool $logDebug
* *
* @throws \RuntimeException * @throws \RuntimeException
*/ */
public function __construct($logFile, $logDebug = false){ public function __construct(string $logFile, bool $logDebug = false){
if(static::$logger instanceof MainLogger){ if(static::$logger instanceof MainLogger){
throw new \RuntimeException("MainLogger has been already created"); throw new \RuntimeException("MainLogger has been already created");
} }
touch($logFile); touch($logFile);
$this->logFile = $logFile; $this->logFile = $logFile;
$this->logDebug = (bool) $logDebug; $this->logDebug = $logDebug;
$this->logStream = new \Threaded; $this->logStream = new \Threaded;
$this->start(); $this->start();
} }
@ -109,8 +114,8 @@ class MainLogger extends \AttachableThreadedLogger{
/** /**
* @param bool $logDebug * @param bool $logDebug
*/ */
public function setLogDebug($logDebug){ public function setLogDebug(bool $logDebug){
$this->logDebug = (bool) $logDebug; $this->logDebug = $logDebug;
} }
public function logException(\Throwable $e, $trace = null){ public function logException(\Throwable $e, $trace = null){