Added defined http logger class in the config

This commit is contained in:
Alex Renoki 2020-08-13 10:15:52 +03:00
parent fddf4d561b
commit 5e0ec9e6a1
2 changed files with 9 additions and 1 deletions

View File

@ -81,6 +81,12 @@ return [
*/ */
'model' => \BeyondCode\LaravelWebSockets\Statistics\Models\WebSocketsStatisticsEntry::class, '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. * Here you can specify the interval in seconds at which statistics should be logged.
*/ */

View File

@ -61,7 +61,9 @@ class StartWebSocketServer extends Command
$browser = new Browser($this->loop, $connector); $browser = new Browser($this->loop, $connector);
app()->singleton(StatisticsLoggerInterface::class, function () use ($browser) { 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 () { $this->loop->addPeriodicTimer(config('websockets.statistics.interval_in_seconds'), function () {