<?php

declare(strict_types=1);

namespace Apexl\Io\Notifier\Notifiers;

use Apexl\Io\Logger\Interfaces\LoggerInterface;
use Apexl\Io\Logger\Services\LoggerStore;
use Apexl\Io\Notifier\Interfaces\NotifierInterface;
use Apexl\Io\Notifier\Logger\ErrorLogLogger;
use Exception;

abstract class Notifier implements NotifierInterface
{
    protected LoggerInterface $logger;

    /**
     * @throws Exception
     */
    public function __construct()
    {
        $stream = \Apexl\Config\config('notifier.log_stream', LoggerStore::DEFAULT__LOGGER_STREAM);

        $this->logger = class_exists('Apexl\Io\Modules\LoggerModule') ?
            \Apexl\Io\Logger\logger($stream) : new ErrorLogLogger();
    }
}
