1 | <?php declare(strict_types=1); |
||
14 | class ClimateLogger implements Logger |
||
15 | { |
||
16 | const WARNING_TEMPLATE = <<<EOD |
||
17 | <yellow> |
||
18 | ############################################################################################################## |
||
19 | <bold>WARNING</bold> |
||
20 | %s |
||
21 | |||
22 | ############################################################################################################## |
||
23 | </yellow> |
||
24 | EOD; |
||
25 | |||
26 | |||
27 | /** |
||
28 | * @var CLImate |
||
29 | */ |
||
30 | public $cliMate; |
||
31 | |||
32 | /** |
||
33 | * @var int |
||
34 | */ |
||
35 | private $scriptStartTime; |
||
36 | |||
37 | /** |
||
38 | * @var Duration |
||
39 | */ |
||
40 | private $duration; |
||
41 | |||
42 | /** |
||
43 | * @param CLImate $cliMate |
||
44 | * @param Duration $duration |
||
45 | */ |
||
46 | public function __construct(CLImate $cliMate, Duration $duration) |
||
51 | |||
52 | /** |
||
53 | * @param Script $script |
||
54 | */ |
||
55 | public function startScript(Script $script) |
||
60 | |||
61 | /** |
||
62 | * @param Script $script |
||
63 | */ |
||
64 | public function finishScript(Script $script) |
||
74 | |||
75 | /** |
||
76 | * @param string $response |
||
77 | * @return string |
||
78 | */ |
||
79 | private function formatOutput(string $response) :string |
||
83 | |||
84 | /** |
||
85 | * @return void |
||
86 | */ |
||
87 | public function logWait() |
||
91 | |||
92 | public function log(LogMessage $logMessage) |
||
100 | |||
101 | /** |
||
102 | * @param string $response |
||
103 | */ |
||
104 | private function err(string $response) |
||
108 | |||
109 | /** |
||
110 | * @param string $response |
||
111 | */ |
||
112 | private function out(string $response) |
||
116 | |||
117 | /** |
||
118 | * @param string $headline |
||
119 | * @param string $subject |
||
120 | * @param int $line |
||
121 | * @param bool $isIgnoreError |
||
122 | * @param int $index |
||
123 | * @param int $max |
||
124 | */ |
||
125 | public function logStart(string $headline, string $subject, int $line, bool $isIgnoreError, int $index, int $max) |
||
130 | |||
131 | public function logSuccess() |
||
135 | |||
136 | public function logFailure() |
||
137 | { |
||
138 | $this->cliMate->green()->red()->out('Executed with failure'); |
||
139 | } |
||
140 | |||
141 | public function warn(string $message) |
||
145 | } |
||
146 |