1 | <?php |
||
10 | class ConsoleOutputter implements IOutputter, ILazyWriter |
||
11 | { |
||
12 | /** |
||
13 | * https://github.com/php/php-src/tree/master/sapi |
||
14 | * PHP7以前のものは対応しない |
||
15 | * @var SAPIリスト |
||
16 | */ |
||
17 | private $sapis = [ |
||
18 | 'apache2handler' => 'http', |
||
19 | 'cgi' => 'http', |
||
20 | 'cli' => 'console', |
||
21 | 'fpm' => 'http', |
||
22 | 'embed' => 'unsupported', |
||
23 | 'litespeed' => 'unsupported', |
||
24 | 'phpdbg' => 'unsupported', |
||
25 | 'tests' => 'unsupported' |
||
26 | ]; |
||
27 | |||
28 | /** |
||
29 | * @var array<string> ログメッセージリスト |
||
30 | */ |
||
31 | private $logMessages; |
||
32 | |||
33 | /** |
||
34 | * @var int バッファリングサイズ |
||
35 | */ |
||
36 | private $bufferSize; |
||
37 | |||
38 | /** |
||
39 | * @var bool 遅延書き出しフラグ |
||
40 | */ |
||
41 | private $isLazyWrite; |
||
42 | |||
43 | /** |
||
44 | * constructor |
||
45 | */ |
||
46 | 126 | public function __construct($bufferSize = 1000) |
|
52 | |||
53 | /** |
||
54 | * destructor |
||
55 | */ |
||
56 | 1 | public function __destruct() |
|
57 | { |
||
58 | 1 | $this->writeLog(implode("", $this->logMessages)); |
|
59 | 1 | } |
|
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | 1 | public function enableLazyWrite() |
|
68 | |||
69 | /** |
||
70 | * {@inheritdoc} |
||
71 | */ |
||
72 | 3 | public function enableDirectWrite() |
|
77 | |||
78 | /** |
||
79 | * {@inheritdoc} |
||
80 | */ |
||
81 | 82 | public function write($message) |
|
93 | |||
94 | /** |
||
95 | * バッファをクリアする |
||
96 | */ |
||
97 | 1 | private function clear() |
|
101 | |||
102 | /** |
||
103 | * バッファをログ出力する |
||
104 | */ |
||
105 | 3 | private function flush() |
|
112 | |||
113 | /** |
||
114 | * ログファイルに書き出す |
||
115 | * @param string $message ログメッセージ |
||
116 | */ |
||
117 | 83 | private function writeLog($message) |
|
124 | } |
||
125 |