Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 79ef005

Browse files
authored
Merge pull request #442 from beyondcode/feature/custom-http-stats-logger
[feature] Custom HttpStatisticsLogger instance
2 parents 102901f + 248e1c2 commit 79ef005

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

config/websockets.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@
8181
*/
8282
'model' => \BeyondCode\LaravelWebSockets\Statistics\Models\WebSocketsStatisticsEntry::class,
8383

84+
/**
85+
* The Statistics Logger will, by default, handle the incoming statistics, store them
86+
* and then release them into the database on each interval defined below.
87+
*/
88+
'logger' => \BeyondCode\LaravelWebSockets\Statistics\Logger::class,
89+
8490
/*
8591
* Here you can specify the interval in seconds at which statistics should be logged.
8692
*/

src/Console/StartWebSocketServer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use BeyondCode\LaravelWebSockets\Server\Logger\WebsocketsLogger;
1010
use BeyondCode\LaravelWebSockets\Server\WebSocketServerFactory;
1111
use BeyondCode\LaravelWebSockets\Statistics\DnsResolver;
12-
use BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger;
1312
use BeyondCode\LaravelWebSockets\Statistics\Logger\StatisticsLogger as StatisticsLoggerInterface;
1413
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
1514
use Clue\React\Buzz\Browser;
@@ -61,7 +60,9 @@ protected function configureStatisticsLogger()
6160
$browser = new Browser($this->loop, $connector);
6261

6362
app()->singleton(StatisticsLoggerInterface::class, function () use ($browser) {
64-
return new HttpStatisticsLogger(app(ChannelManager::class), $browser);
63+
$class = config('websockets.statistics.logger', \BeyondCode\LaravelWebSockets\Statistics\Logger::class);
64+
65+
return new $class(app(ChannelManager::class), $browser);
6566
});
6667

6768
$this->loop->addPeriodicTimer(config('websockets.statistics.interval_in_seconds'), function () {

0 commit comments

Comments
 (0)