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
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
4 changed files with 34 additions and 22 deletions

View File

@ -40,8 +40,8 @@
"pocketmine/classloader": "^0.2.0", "pocketmine/classloader": "^0.2.0",
"pocketmine/color": "^0.2.0", "pocketmine/color": "^0.2.0",
"pocketmine/errorhandler": "^0.3.0", "pocketmine/errorhandler": "^0.3.0",
"pocketmine/log": "^0.3.0", "pocketmine/log": "^0.4.0",
"pocketmine/log-pthreads": "^0.2.0", "pocketmine/log-pthreads": "^0.4.0",
"pocketmine/math": "^0.4.0", "pocketmine/math": "^0.4.0",
"pocketmine/nbt": "^0.3.0", "pocketmine/nbt": "^0.3.0",
"pocketmine/raklib": "^0.14.2", "pocketmine/raklib": "^0.14.2",

30
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "3aab4c7b78ea85bf5e68e8b953cd9e1f", "content-hash": "9b3c01e7b850d45218b81a436f463011",
"packages": [ "packages": [
{ {
"name": "adhocore/json-comment", "name": "adhocore/json-comment",
@ -508,16 +508,16 @@
}, },
{ {
"name": "pocketmine/log", "name": "pocketmine/log",
"version": "0.3.0", "version": "0.4.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/pmmp/Log.git", "url": "https://github.com/pmmp/Log.git",
"reference": "03ab1316da0b1978a7a1c8dd73e1c2a973cb62ec" "reference": "e6c912c0f9055c81d23108ec2d179b96f404c043"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/pmmp/Log/zipball/03ab1316da0b1978a7a1c8dd73e1c2a973cb62ec", "url": "https://api.github.com/repos/pmmp/Log/zipball/e6c912c0f9055c81d23108ec2d179b96f404c043",
"reference": "03ab1316da0b1978a7a1c8dd73e1c2a973cb62ec", "reference": "e6c912c0f9055c81d23108ec2d179b96f404c043",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -527,7 +527,7 @@
"pocketmine/spl": "<0.4" "pocketmine/spl": "<0.4"
}, },
"require-dev": { "require-dev": {
"phpstan/phpstan": "0.12.80", "phpstan/phpstan": "0.12.88",
"phpstan/phpstan-strict-rules": "^0.12.2" "phpstan/phpstan-strict-rules": "^0.12.2"
}, },
"type": "library", "type": "library",
@ -543,28 +543,28 @@
"description": "Logging components used by PocketMine-MP and related projects", "description": "Logging components used by PocketMine-MP and related projects",
"support": { "support": {
"issues": "https://github.com/pmmp/Log/issues", "issues": "https://github.com/pmmp/Log/issues",
"source": "https://github.com/pmmp/Log/tree/0.3.0" "source": "https://github.com/pmmp/Log/tree/0.4.0"
}, },
"time": "2021-05-18T21:00:49+00:00" "time": "2021-06-18T19:08:09+00:00"
}, },
{ {
"name": "pocketmine/log-pthreads", "name": "pocketmine/log-pthreads",
"version": "0.2.1", "version": "0.4.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/pmmp/LogPthreads.git", "url": "https://github.com/pmmp/LogPthreads.git",
"reference": "26f51ed44b1884f6dd72c06a883d9d07613af4f1" "reference": "61f709e8cf36bcc24e4efe02acded680a1ce23cd"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/pmmp/LogPthreads/zipball/26f51ed44b1884f6dd72c06a883d9d07613af4f1", "url": "https://api.github.com/repos/pmmp/LogPthreads/zipball/61f709e8cf36bcc24e4efe02acded680a1ce23cd",
"reference": "26f51ed44b1884f6dd72c06a883d9d07613af4f1", "reference": "61f709e8cf36bcc24e4efe02acded680a1ce23cd",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-pthreads": "~3.2.0 || ^4.0", "ext-pthreads": "~3.2.0 || ^4.0",
"php": "^7.4 || ^8.0", "php": "^7.4 || ^8.0",
"pocketmine/log": "^0.2.0 || ^0.3.0" "pocketmine/log": "^0.4.0"
}, },
"conflict": { "conflict": {
"pocketmine/spl": "<0.4" "pocketmine/spl": "<0.4"
@ -587,9 +587,9 @@
"description": "Logging components specialized for pthreads used by PocketMine-MP and related projects", "description": "Logging components specialized for pthreads used by PocketMine-MP and related projects",
"support": { "support": {
"issues": "https://github.com/pmmp/LogPthreads/issues", "issues": "https://github.com/pmmp/LogPthreads/issues",
"source": "https://github.com/pmmp/LogPthreads/tree/0.2.1" "source": "https://github.com/pmmp/LogPthreads/tree/0.4.0"
}, },
"time": "2021-11-01T20:41:37+00:00" "time": "2021-11-01T21:42:09+00:00"
}, },
{ {
"name": "pocketmine/math", "name": "pocketmine/math",

View File

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

View File

@ -210,7 +210,7 @@ class MainLogger extends \AttachableThreadedLogger implements \BufferedLogger{
$this->logWriterThread->write($time->format("Y-m-d") . " " . TextFormat::clean($message) . PHP_EOL); $this->logWriterThread->write($time->format("Y-m-d") . " " . TextFormat::clean($message) . PHP_EOL);
foreach($this->attachments as $attachment){ foreach($this->attachments as $attachment){
$attachment->call($level, $message); $attachment->log($level, $message);
} }
}); });
} }