1 | <?php |
||
19 | class ConsoleLogger extends AbstractLogger |
||
20 | { |
||
21 | private $levelToInt = array( |
||
22 | LogLevel::DEBUG => 10, |
||
23 | LogLevel::INFO => 20, |
||
24 | LogLevel::NOTICE => 30, |
||
25 | LogLevel::WARNING => 40, |
||
26 | LogLevel::ERROR => 50, |
||
27 | LogLevel::CRITICAL => 60, |
||
28 | LogLevel::ALERT => 70, |
||
29 | LogLevel::EMERGENCY => 80 |
||
30 | ); |
||
31 | |||
32 | /** |
||
33 | * @var array |
||
34 | */ |
||
35 | private $verbosityLevelMap = array( |
||
36 | LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL, |
||
37 | LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL, |
||
38 | LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL, |
||
39 | LogLevel::ERROR => OutputInterface::VERBOSITY_NORMAL, |
||
40 | LogLevel::WARNING => OutputInterface::VERBOSITY_NORMAL, |
||
41 | LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE, |
||
42 | LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE, |
||
43 | LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG, |
||
44 | ); |
||
45 | |||
46 | /** |
||
47 | * @var OutputInterface |
||
48 | */ |
||
49 | private $output; |
||
50 | |||
51 | /** |
||
52 | * @var string |
||
53 | */ |
||
54 | private $levelThresholdToStderr; |
||
55 | |||
56 | /** |
||
57 | * @var ConsoleMessageDecorator|null |
||
58 | */ |
||
59 | private $decorator; |
||
60 | |||
61 | /** |
||
62 | * @param OutputInterface $output |
||
63 | * @param string $levelThresholdToStderr |
||
64 | * @param array $verbosityLevelMap |
||
65 | * @param ConsoleMessageDecorator|null $decorator |
||
66 | */ |
||
67 | public function __construct( |
||
78 | |||
79 | /** |
||
80 | * {@inheritdoc} |
||
81 | */ |
||
82 | public function log($level, $message, array $context = array()) |
||
95 | |||
96 | /** |
||
97 | * Interpolates context values into the message placeholders |
||
98 | * |
||
99 | * @author PHP Framework Interoperability Group |
||
100 | * |
||
101 | * @param string $message |
||
102 | * @param array $context |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | private function interpolate($message, array $context) |
||
119 | |||
120 | /** |
||
121 | * @param $level |
||
122 | * @return bool |
||
123 | */ |
||
124 | private function isStderrThresholdReached($level) |
||
128 | |||
129 | /** |
||
130 | * @param $level |
||
131 | * @param $message |
||
132 | * @return string |
||
133 | */ |
||
134 | private function getDecoratedMessage($level, $message) |
||
138 | } |