<?php

declare (strict_types=1);
/*
 * This file is part of the Monolog package.
 *
 * (c) Jordi Boggiano <j.boggiano@seld.be>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace WPCal\GoogleAPI\Monolog\Handler;

use WPCal\GoogleAPI\Monolog\Logger;
use WPCal\GoogleAPI\Monolog\Formatter\NormalizerFormatter;
use WPCal\GoogleAPI\Monolog\Formatter\FormatterInterface;
use WPCal\GoogleAPI\Doctrine\CouchDB\CouchDBClient;
/**
 * CouchDB handler for Doctrine CouchDB ODM
 *
 * @author Markus Bachmann <markus.bachmann@bachi.biz>
 */
class DoctrineCouchDBHandler extends \WPCal\GoogleAPI\Monolog\Handler\AbstractProcessingHandler
{
    private $client;
    public function __construct(\WPCal\GoogleAPI\Doctrine\CouchDB\CouchDBClient $client, $level = \WPCal\GoogleAPI\Monolog\Logger::DEBUG, bool $bubble = \true)
    {
        $this->client = $client;
        parent::__construct($level, $bubble);
    }
    /**
     * {@inheritDoc}
     */
    protected function write(array $record) : void
    {
        $this->client->postDocument($record['formatted']);
    }
    protected function getDefaultFormatter() : \WPCal\GoogleAPI\Monolog\Formatter\FormatterInterface
    {
        return new \WPCal\GoogleAPI\Monolog\Formatter\NormalizerFormatter();
    }
}
