nethergamesmc/liblokilogger

This package is abandoned and no longer maintained. No replacement package was suggested.

Small and compact Grafana Loki logger for PocketMine-MP

Maintainers

Package info

github.com/NetherGamesMC/libLokiLogger

Type:project

pkg:composer/nethergamesmc/liblokilogger

Statistics

Installs: 3 541

Dependents: 0

Suggesters: 0

Stars: 8

Open Issues: 0

dev-master 2024-11-29 14:45 UTC

This package is auto-updated.

Last update: 2024-12-29 15:04:01 UTC


README

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());