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

[feature] Custom HttpStatisticsLogger instance #442

Merged
merged 5 commits into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/websockets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
5 changes: 3 additions & 2 deletions src/Console/StartWebSocketServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 () {
Expand Down