Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Latest commit

 

History

History
23 lines (17 loc) · 1006 Bytes

README.md

File metadata and controls

23 lines (17 loc) · 1006 Bytes

libLokiLogger

Grafana Loki asynchronous logging utility for PocketMine-MP logger. It will log everything from any threads you want.

Getting started

You will have to initialize and start LokiLoggerThread process in your plugin, you can supply your own composer autoloader path if you are using php's composer.

Here is the code to start using the project:

# Start logging thread.
$lokiFactory = new LokiLoggerThread(COMPOSER_AUTOLOADER_PATH, 'http://localhost: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());