From 09776a18284a2ea400cbf0b08b5949745210ac70 Mon Sep 17 00:00:00 2001 From: Alex Renoki Date: Mon, 17 Aug 2020 21:17:00 +0300 Subject: [PATCH] Refactored the statistics logger --- config/websockets.php | 6 ++- src/Facades/StatisticsLogger.php | 2 +- .../Logger/NullStatisticsLogger.php | 47 +++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 src/Statistics/Logger/NullStatisticsLogger.php diff --git a/config/websockets.php b/config/websockets.php index 1c9f61f..13aac01 100644 --- a/config/websockets.php +++ b/config/websockets.php @@ -191,9 +191,13 @@ return [ | store them into an array and then store them into the database | on each interval. | + | You can opt-in to avoid any statistics storage by setting the logger + | to the built-in NullLogger. + | */ - 'logger' => BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger::class, + 'logger' => \BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger::class, + // 'logger' => \BeyondCode\LaravelWebSockets\Statistics\Logger\NullStatisticsLogger::class, /* |-------------------------------------------------------------------------- diff --git a/src/Facades/StatisticsLogger.php b/src/Facades/StatisticsLogger.php index 9aadfa7..5183342 100644 --- a/src/Facades/StatisticsLogger.php +++ b/src/Facades/StatisticsLogger.php @@ -6,7 +6,7 @@ use BeyondCode\LaravelWebSockets\Statistics\Logger\StatisticsLogger as Statistic use Illuminate\Support\Facades\Facade; /** - * @see \BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger + * @see \BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger * @mixin \BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger */ class StatisticsLogger extends Facade diff --git a/src/Statistics/Logger/NullStatisticsLogger.php b/src/Statistics/Logger/NullStatisticsLogger.php new file mode 100644 index 0000000..885703e --- /dev/null +++ b/src/Statistics/Logger/NullStatisticsLogger.php @@ -0,0 +1,47 @@ +channelManager = $channelManager; + $this->browser = $browser; + } + + public function webSocketMessage(ConnectionInterface $connection) + { + // + } + + public function apiMessage($appId) + { + // + } + + public function connection(ConnectionInterface $connection) + { + // + } + + public function disconnection(ConnectionInterface $connection) + { + // + } + + public function save() + { + // + } +}