hryvinskyi /
magento2-invisible-captcha
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Copyright (c) 2020. Volodymyr Hryvinskyi. All rights reserved. |
||
| 4 | * @author: <mailto:[email protected]> |
||
| 5 | * @github: <https://github.com/hryvinskyi> |
||
| 6 | */ |
||
| 7 | |||
| 8 | declare(strict_types=1); |
||
| 9 | |||
| 10 | namespace Hryvinskyi\InvisibleCaptcha\Model; |
||
| 11 | |||
| 12 | use Hryvinskyi\InvisibleCaptcha\Helper\Config\General; |
||
| 13 | use Magento\Framework\Filesystem\DriverInterface; |
||
| 14 | use Magento\Framework\Logger\Handler\Base; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Class Debug |
||
| 18 | */ |
||
| 19 | class Debug extends Base |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * @var General |
||
| 23 | */ |
||
| 24 | private $config; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Debug constructor. |
||
| 28 | * |
||
| 29 | * @param DriverInterface $filesystem |
||
| 30 | * @param General $config |
||
| 31 | * @param null $filePath |
||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
| 32 | * @param string $fileName |
||
| 33 | * |
||
| 34 | * @throws \Exception |
||
| 35 | */ |
||
| 36 | public function __construct( |
||
| 37 | DriverInterface $filesystem, |
||
| 38 | General $config, |
||
| 39 | $filePath = null, |
||
| 40 | $fileName = '/var/log/invisible_captcha.log' |
||
| 41 | ) { |
||
| 42 | parent::__construct($filesystem, $filePath, $fileName); |
||
| 43 | |||
| 44 | $this->config = $config; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @inheritDoc |
||
| 49 | * @throws \Magento\Framework\Exception\FileSystemException |
||
| 50 | */ |
||
| 51 | public function write(array $record) |
||
| 52 | { |
||
| 53 | if ($this->config->isDebug() === false) { |
||
| 54 | return; |
||
| 55 | } |
||
| 56 | |||
| 57 | $logDir = $this->filesystem->getParentDirectory($this->url); |
||
| 58 | if (!$this->filesystem->isDirectory($logDir)) { |
||
| 59 | $this->filesystem->createDirectory($logDir); |
||
| 60 | } |
||
| 61 | |||
| 62 | parent::write($record); |
||
| 63 | } |
||
| 64 | } |