Updated pocketmine/log and pocketmine/log-pthreads (BC breaks included)

AttachableLogger deals with Closures now instead of LoggerAttachment objects
ThreadedLoggerAttachment no longer implements LoggerAttachment
This commit is contained in:
Dylan K. Taylor
2021-11-01 22:22:22 +00:00
parent f6cb4f9597
commit f2912fcdd8
4 changed files with 34 additions and 22 deletions

View File

@@ -25,16 +25,28 @@ namespace pocketmine\plugin;
use function spl_object_id;
/**
* @phpstan-import-type LoggerAttachment from \AttachableLogger
*/
class PluginLogger extends \PrefixedLogger implements \AttachableLogger{
/** @var \LoggerAttachment[] */
/**
* @var \Closure[]
* @phpstan-var LoggerAttachment[]
*/
private $attachments = [];
public function addAttachment(\LoggerAttachment $attachment){
/**
* @phpstan-param LoggerAttachment $attachment
*/
public function addAttachment(\Closure $attachment){
$this->attachments[spl_object_id($attachment)] = $attachment;
}
public function removeAttachment(\LoggerAttachment $attachment){
/**
* @phpstan-param LoggerAttachment $attachment
*/
public function removeAttachment(\Closure $attachment){
unset($this->attachments[spl_object_id($attachment)]);
}
@@ -49,7 +61,7 @@ class PluginLogger extends \PrefixedLogger implements \AttachableLogger{
public function log($level, $message){
parent::log($level, $message);
foreach($this->attachments as $attachment){
$attachment->log($level, $message);
$attachment($level, $message);
}
}
}