DoctrineCouchDBHandler.php 1000 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /*
  3. * This file is part of the Monolog package.
  4. *
  5. * (c) Jordi Boggiano <j.boggiano@seld.be>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Monolog\Handler;
  11. use Monolog\Logger;
  12. use Monolog\Formatter\NormalizerFormatter;
  13. use Doctrine\CouchDB\CouchDBClient;
  14. /**
  15. * CouchDB handler for Doctrine CouchDB ODM
  16. *
  17. * @author Markus Bachmann <markus.bachmann@bachi.biz>
  18. */
  19. class DoctrineCouchDBHandler extends AbstractProcessingHandler
  20. {
  21. private $client;
  22. public function __construct(CouchDBClient $client, $level = Logger::DEBUG, $bubble = true)
  23. {
  24. $this->client = $client;
  25. parent::__construct($level, $bubble);
  26. }
  27. /**
  28. * {@inheritDoc}
  29. */
  30. protected function write(array $record)
  31. {
  32. $this->client->postDocument($record['formatted']);
  33. }
  34. protected function getDefaultFormatter()
  35. {
  36. return new NormalizerFormatter;
  37. }
  38. }