DefaultLogger.php 793 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace Stripe\Util;
  3. /**
  4. * A very basic implementation of LoggerInterface that has just enough
  5. * functionality that it can be the default for this library.
  6. */
  7. class DefaultLogger implements LoggerInterface
  8. {
  9. /** @var int */
  10. public $messageType = 0;
  11. /** @var null|string */
  12. public $destination;
  13. public function error($message, array $context = [])
  14. {
  15. if (\count($context) > 0) {
  16. throw new \Stripe\Exception\BadMethodCallException('DefaultLogger does not currently implement context. Please implement if you need it.');
  17. }
  18. if (null === $this->destination) {
  19. \error_log($message, $this->messageType);
  20. } else {
  21. \error_log($message, $this->messageType, $this->destination);
  22. }
  23. }
  24. }