-
Notifications
You must be signed in to change notification settings - Fork 3
3. Logging
Exanlv edited this page Nov 21, 2023
·
1 revision
Sometimes it may be useful to inspect what Fenrir is doing in the background. For this you can pass a PSR-3 compatible logger. The one used in this example, is a Monolog logger.
This logging will contain HTTP requests being made and all packets sent to and from Discords Gateway.
<?php
use Ragnarok\Fenrir\Discord;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Ragnarok\Fenrir\Bitwise\Bitwise;
$log = new Logger('name', [new StreamHandler('/path/to/your.log')]); // Log to a file
$log = new Logger('name', [new StreamHandler('php://stdout')]); // Log to stdout (terminal output)
$discord = new Discord(
'TOKEN',
$log
);
$discord
->withGateway(new Bitwise())
->withRest();
$discord->gateway->connect(); // Nothing after this line is executedNote: Monologger is not always an optimal solution as it does not integrate with the ReactPHP event loop to access files. If you want to log to a file, consider using one of the loggers found built with ReactPHP