Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
Logger
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
 level
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 error
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Dynart\Micro;
4
5use Katzgrau\KLogger\Logger as KLogger;
6
7class Logger extends KLogger {
8
9    const CONFIG_DIR = 'log.dir';
10    const DEFAULT_DIR = 'logs';
11
12    const CONFIG_LEVEL = 'log.level';
13    const DEFAULT_LEVEL = 'error';
14
15    const CONFIG_OPTIONS = 'log.options';
16    const DEFAULT_OPTIONS = [];
17
18    const DEBUG = 'debug';
19    const INFO = 'info';
20    const WARNING = 'warning';
21    const ERROR = 'error';
22
23    /** @var string */
24    private $level;
25
26    public function __construct(Config $config) {
27        parent::__construct(
28            $config->get(self::CONFIG_DIR, self::DEFAULT_DIR),
29            $config->get(self::CONFIG_LEVEL, self::DEFAULT_LEVEL),
30            $config->getArray(self::CONFIG_OPTIONS, self::DEFAULT_OPTIONS)
31        );
32        $this->level = $config->get(self::CONFIG_LEVEL, self::DEFAULT_LEVEL);
33    }
34
35    public function level(): string {
36        return $this->level;
37    }
38
39    public function error($message, array $context = array()) {
40        parent::error($message, $context);
41        error_log($message); // always log errors
42    }
43}