Total Complexity | 7 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
7 | final class FileLogger extends AbstractLogger implements \WebServCo\Framework\Interfaces\FileLoggerInterface |
||
8 | { |
||
9 | protected $channel; |
||
10 | protected $logDir; |
||
11 | protected $logPath; |
||
12 | protected $requestInterface; |
||
13 | |||
14 | public function __construct($channel, $logDir, RequestInterface $requestInterface) |
||
15 | { |
||
16 | $this->channel = $channel; |
||
17 | $this->logDir = $logDir; |
||
18 | |||
19 | if (!is_readable($this->logDir)) { |
||
20 | throw new ApplicationException('Log directory not readable'); |
||
21 | } |
||
22 | if (!is_writable($this->logDir)) { |
||
23 | throw new ApplicationException('Log directory not writeable'); |
||
24 | } |
||
25 | $this->logPath = sprintf('%s%s.log', $this->logDir, $this->channel); |
||
26 | |||
27 | $this->requestInterface = $requestInterface; |
||
28 | } |
||
29 | |||
30 | public function clear() |
||
31 | { |
||
32 | return file_put_contents($this->logPath, null); |
||
33 | } |
||
34 | |||
35 | public function getLogDirectory() |
||
38 | } |
||
39 | |||
40 | public function log($level, $message, $context = []) |
||
54 | } |
||
55 | } |
||
56 |