nethergamesmc / liblokilogger
小型且紧凑的Grafana Loki日志记录器,适用于PocketMine-MP
dev-master
2024-09-26 14:38 UTC
Requires
- php: ^8.0
Requires (Dev)
- phpstan/phpstan: 1.12.5
- pocketmine/pocketmine-mp: dev-stable
This package is auto-updated.
Last update: 2024-09-26 14:39:28 UTC
README
Grafana Loki 异步日志实用工具,用于PocketMine-MP日志记录器。它将记录您想要记录的任何线程的所有内容。
入门指南
您需要在您的插件中初始化并启动 LokiLoggerThread
进程,如果您使用php的composer,您可以提供自己的composer自动加载器路径。
以下是开始使用此项目的代码
# Start logging thread. $lokiFactory = new LokiLoggerThread(COMPOSER_AUTOLOADER_PATH, 'https://:1300', ['app' => 'lobby-1', 'region' => 'ap', 'server-id' => '1']); $lokiFactory->start(); $this->getServer()->getAsyncPool()->addWorkerStartHook(function (int $workerId) use ($lokiFactory): void { $this->getServer()->getAsyncPool()->submitTaskToWorker(new LokiRegisterAsyncTask($lokiFactory), $workerId); }); # Add an attachment to the server's logger, this will log everything in console into grafana loki. Server::getInstance()->getLogger()->addAttachment(new LokiLoggerAttachment());