diff --git a/config/websockets.php b/config/websockets.php index 6a2e7f0379..a4517cfd70 100644 --- a/config/websockets.php +++ b/config/websockets.php @@ -81,6 +81,12 @@ */ 'model' => \BeyondCode\LaravelWebSockets\Statistics\Models\WebSocketsStatisticsEntry::class, + /** + * The Statistics Logger will, by default, handle the incoming statistics, store them + * and then release them into the database on each interval defined below. + */ + 'logger' => \BeyondCode\LaravelWebSockets\Statistics\Logger::class, + /* * Here you can specify the interval in seconds at which statistics should be logged. */ diff --git a/src/Console/StartWebSocketServer.php b/src/Console/StartWebSocketServer.php index e68767c986..968f94ac9d 100644 --- a/src/Console/StartWebSocketServer.php +++ b/src/Console/StartWebSocketServer.php @@ -9,7 +9,6 @@ use BeyondCode\LaravelWebSockets\Server\Logger\WebsocketsLogger; use BeyondCode\LaravelWebSockets\Server\WebSocketServerFactory; use BeyondCode\LaravelWebSockets\Statistics\DnsResolver; -use BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger; use BeyondCode\LaravelWebSockets\Statistics\Logger\StatisticsLogger as StatisticsLoggerInterface; use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager; use Clue\React\Buzz\Browser; @@ -61,7 +60,9 @@ protected function configureStatisticsLogger() $browser = new Browser($this->loop, $connector); app()->singleton(StatisticsLoggerInterface::class, function () use ($browser) { - return new HttpStatisticsLogger(app(ChannelManager::class), $browser); + $class = config('websockets.statistics.logger', \BeyondCode\LaravelWebSockets\Statistics\Logger::class); + + return new $class(app(ChannelManager::class), $browser); }); $this->loop->addPeriodicTimer(config('websockets.statistics.interval_in_seconds'), function () {