| Total Complexity | 6 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | class Logfile extends LogOutputAbstract{ |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var bool|resource |
||
| 24 | */ |
||
| 25 | protected $fh; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Logfile constructor. |
||
| 29 | * |
||
| 30 | * @param \chillerlan\Traits\ContainerInterface|null $options |
||
| 31 | * |
||
| 32 | * @throws \chillerlan\Logger\LogException |
||
| 33 | */ |
||
| 34 | public function __construct(ContainerInterface $options = null){ |
||
| 35 | parent::__construct($options); |
||
| 36 | |||
| 37 | if(!is_writable($this->options->logfileDir)){ |
||
| 38 | throw new LogException('log file directory inaccessible'); |
||
| 39 | } |
||
| 40 | |||
| 41 | $logfile = $this->options->logfileDir.'/'.$this->options->logfileName.'-'.date('Y-m-d').'.'.$this->options->logfileExt; |
||
| 42 | |||
| 43 | $this->fh = fopen($logfile, 'a+'); |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @inheritdoc |
||
| 48 | */ |
||
| 49 | public function __destruct(){ |
||
| 50 | $this->close(); |
||
| 51 | |||
| 52 | if(gettype($this->fh) === 'resource'){ |
||
| 53 | fclose($this->fh); |
||
| 54 | } |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @inheritdoc |
||
| 59 | */ |
||
| 60 | protected function __log(string $level, string $message, array $context = null){ |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @inheritdoc |
||
| 66 | */ |
||
| 67 | public function close():LogOutputInterface{ |
||
| 70 | } |
||
| 71 | |||
| 73 |