LogBroadcaster.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace Illuminate\Broadcasting\Broadcasters;
  3. use Psr\Log\LoggerInterface;
  4. class LogBroadcaster extends Broadcaster
  5. {
  6. /**
  7. * The logger implementation.
  8. *
  9. * @var \Psr\Log\LoggerInterface
  10. */
  11. protected $logger;
  12. /**
  13. * Create a new broadcaster instance.
  14. *
  15. * @param \Psr\Log\LoggerInterface $logger
  16. * @return void
  17. */
  18. public function __construct(LoggerInterface $logger)
  19. {
  20. $this->logger = $logger;
  21. }
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function auth($request)
  26. {
  27. //
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function validAuthenticationResponse($request, $result)
  33. {
  34. //
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function broadcast(array $channels, $event, array $payload = [])
  40. {
  41. $channels = implode(', ', $this->formatChannels($channels));
  42. $payload = json_encode($payload, JSON_PRETTY_PRINT);
  43. $this->logger->info('Broadcasting ['.$event.'] on channels ['.$channels.'] with payload:'.PHP_EOL.$payload);
  44. }
  45. }