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

NetherGamesMC/libLokiLogger

Repository files navigation

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

About

Grafana Loki log exporter for PocketMine-MP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages